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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function call

Status
Not open for further replies.

Simse

Programmer
Feb 24, 2005
22
Hi,
could someone please tell me how to call a function

void CMyPropertySheet::OnButtonCalculate()

out of another function (in a different file)

BOOL CGeneral::OnSetActive() ???

I suppose, it can't be that difficult but either i'm too stupid or it's because today is friday ;-)

Thx
 
Simse,

You nned to have an instance of that class declared where your calling it.

Code:
[blue]
void CMyPropertySheet::OnButtonCalculate()
{  
   CGeneral myMember = new CGeneral();
   myMember.OnSetActive();
}

[/blue]

But please note, the member can be a class member and does not have to be initialized inside a function, but you must declare an object of type CGeneral somewhere in order to use it.


Hope that helps,
Ron

typedef map<GiantX,gold, less<std::shortestpathtogold> > AwesomeMap;
 
ronny,

Your code needs to be

void CMyPropertySheet::OnButtonCalculate()
{
CGeneral* myMember = new CGeneral();
myMember->OnSetActive();
}

or you can use

void CMyPropertySheet::OnButtonCalculate()
{
CGeneral myMember;
myMember.OnSetActive();
}
 
hm,

so i only have to add those 2 lines to
void CMyPropertySheet::OnButtonCalculate()
and OnButtonCalculate() is executed as soon as CGeneral becomes active??? don't i have to call it in OnSetActive()?
well ok, if i do i get an error: "C2352: illegal call of non-static member" but if i don't the instruction has no effect (except for an assetion, but that's not the problem!).
Shouldn't it be the other way round? That i write the call of CMyPropertySheet::OnButtonCalculate() in OnSetActive()?
I'm confused... [ponder]
Hoping for enlightenment!

Thx
 
ronnyjljr, cdraycott

void CMyPropertySheet::OnButtonCalculate()
{
CGeneral* myMember = new CGeneral();
myMember->OnSetActive();
}

Where's the release of the resources?

This code should include a
Code:
delete myMember

Greetings,
Rick
 
Haha,

Forgive me, I program in Java and apparently I lost my mind posting on a C++ forum (haha) :p

-Ron

typedef map<GiantX,gold, less<std::shortestpathtogold> > AwesomeMap;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top