Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Class function can't access variable

$
0
0
In my header file
class Player {
	public:
		//constructor
		Player();
		Score score_;
		//assessors
		void setName(string inputtedName);
		string getName() const;
		int getScoreAmount() const;		
		//mutators
		void updateScoreAmount(int i);	
		

				
	private:
		string name_;
};
#endif



The function I'm using is
void Player::setName(string inputtedName)
{
	name_ = inputtedName;
}


This function passes a string from the Interface class, which is the player's name that they type in but when the function tries to set name_ to that value it throws up an access violation.

Could anyone shed some light on this please?

Viewing all articles
Browse latest Browse all 51036

Trending Articles