"return" with no value? what that?

void Game::run( HWND hwnd )
{
if ( graphics == NULL ) // if graphics not initialized
return;
.........
.........
if( frameTime < MIN_FRAME_TIME )
{
sleepTime = (DWORD)((MIN_FRAME_TIME - frameTime)*1000);
timeBeginPeriod(1);
Sleep( sleepTime );
timeEndPeriod(1);
return;
}
.....................................
......
}

I now return 0, return 1 and return any other value.
but what does a return without any value do? I sew it several times, but still don't know what it is. and how to use it.
It's the same as any other return, just that the function doesn't return anything (note the void) so you have no value to put there.
@Zhuge
In a int function return 0 will exit the program, and other kind of function return a value, then the function get the value. What will happen when a void function return. same the the int function of return 0? and kill the program?
It simply exits the function early, exactly as if you had reached the end of it.
In a int function return 0 will exit the program

It exits the function, not the whole program.
Unless the function you're exiting is main(), of course!

Andy
Last edited on
Topic archived. No new replies allowed.