Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function Call issue - Please help

Status
Not open for further replies.

pghTech

Technical User
Jul 19, 2006
37
US
This is sort of confusing for me to Post, so I'll do my best and show all my code. I have two .cpp files, one that includes the other's .h file. I have defined the following member variables:
Code:
private:
        bool m_fullscreen

And three public member functions:
Code:
void CGfxOpenGL::SetScreenMode(bool x)
{
	m_fullscreen = x;
}

bool CGfxOpenGL::GetScreenMode()
{
	return m_fullscreen;
}

void CGfxOpenGL::QuestionScreenMode()
{
	if (MessageBox(NULL, 
					"Do you want to run in Fullscreen", 
					"FullScreen Mode", 
					MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1) == IDYES)
	 {
		SetScreenMode(true);
		return;
	 }
	 else
	 {
		SetScreenMode(false);
		return;
	 }
}

In the winmain.cpp source file I have created an object of the class CGfxOpenGL called <setOpenGL> and I wanted to run an IF statement in winmain.cpp that checks if the app is running in fullscreen (which calls to see if the user wants it to run in fullscreen) and if so apply the proceding settings, but I wanted to do the if statement like so:
Code:
if (setOpenGL.GetScreenMode(setOpenGl.SetScreenMode()))
...
...

But I am having the problem that I am obviously defining GetScreenMode with no arguments. So I tried specifying it as <GetScreenMode(CGfxOpenGL a)> so I could pass the function in the other function (CGfxOpenGl.GetScreenMode(
Thanks in advance

but I get an error
error C2664: 'GetScreenMode' : cannot convert parameter 1 from 'void' to 'class CGfxOpenGL

How do I have to set the passing argements?

Thanks
 
The problem is that all functions which are part of a class have a first parameter "this" which is a pointer to the class variable.

I think if you replace the () with (void) it will work.

bool CGfxOpenGL::GetScreenMode(void)
CGfxOpenGL::QuestionScreenMode(void)

Do this both in your C file and your header.
 
Code:
if (setOpenGL.GetScreenMode(setOpenGl.SetScreenMode()))
You have the Get and Set functions reversed. GetScreenMode() doesn't take any parameters, but you are assigning SetScreenMode() to it. Therefore, that if statement makes no sense.
You can't really reverse the functions either since SetScreenMode() doesn't return a bool, so there's nothing for the if statement to compare...

Why does GetScreenMode() return only true or false anyways? What are true and false supposed to represent?
 
Thanks all....

I was actaully on a binge to find out how to call a function as an argument to another function.

Yes your correct my logic for this problem wasn't correct, and I corrected it.

Thanks for all the advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top