Function not modifying parimeter

Started by
1 comment, last by Thrust 18 years, 3 months ago
Hi, I wrote a function in my game class to take in user input:

void Game::Getinput(std::string blah)
{
	int done = 0;
	while(done==0)
	{
		SDL_Event event;
		while ( SDL_PollEvent(&event) )
			{
				if ( event.type == SDL_KEYDOWN )
				{
			
					if ( event.key.keysym.sym == SDLK_ESCAPE ) 
					{blah="ass"; done++;}
					if ( event.key.keysym.sym == SDLK_RETURN ) {done++;}
					if ( event.key.keysym.sym == SDLK_a) {blah=blah+"a";}
				}

			}
	}
}

If I pass in a variable from my map class, g_map.mapname, it will not modify it. I dont understand why. Can you tell me what im doing wrong?
Mark St. Jean - OwnerWastedInkVwmaggotwV@Yahoo.com
Advertisement
You need to use the parameter type std::string &blah. That way it is passed in as a reference to the original object, instead of a new instance of it.
Thanks a bundle
Mark St. Jean - OwnerWastedInkVwmaggotwV@Yahoo.com

This topic is closed to new replies.

Advertisement