As the title states, I'm getting a "'&' requires l-value" error from the following code:
void InitTitleScreen();
void CSystem::PlayMovie(const char *filename, void *func(void))
{
//TODO: Play movie ....
//Call the end-function at the end of the movie
*func();
}
void CSystem::GameLoop()
{
switch (g_nGameState)
{
case STATE_INITIALIZATION:
{
PlayMovie("data\\Intro.mov", &InitTitleScreen());
}
break;
}
}
void InitTitleScreen()
{
MessageBox(NULL, L"TEST", L"Function pointers suck...", MB_OK);
}
The line that is giving me the error is:
PlayMovie("data\\Intro.mov", &InitTitleScreen());
I've read and re-read tutorials on function pointers ... and can easily do it in C#, but I want to do it in C++ and it is just a little frustrating.
The way I'm seeing it, &InitTitleScreen() is the address of InitTitleScreen(), and I pass that to the PlayMovie function, which then calls the function through the parameter. I know that the "l-value" thing means that there is no value to assign from that, but that doesn't make sense, because shouldn't the function have an address?
I also tried doing the following:
void *FuncPtr = &InitTitleScreen
but that didn't help me much either ... just more errors...