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";}
}
}
}
}
Function not modifying parimeter
Hi,
I wrote a function in my game class to take in user input:
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?
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement