I'm having a bit of trouble with friend functions and classes...
I know that you can have a class be freely accessed by a certain function if you use the friend operator...
Code:
class MyClassType;
int A( MyClassType* MyClass );
class MyClassType
{
friend int A( MyClassType* MyClass );
private:
int B;
};
int A( MyClassType* MyClass )
{
MyClass->B = 3;
}
IIRC, this lets A() access anything it wants in the MyClassType. What do I do if I only want A() to be able to call one function in a certain class?
Code:
class GCoreType;
bool HandleEvent( GCoreType* Core, EventType* Event );
class GCoreType
{
private:
... // Data and stuff
bool ReceiveCommandFromHandleEvent( int Command ) friend bool HandleEvent( GCoreType* Core, EventType* Event );
public:
... // Other stuff
};
bool HandleEvent( GCoreType* Core, EventType* Event )
{
if( Event->eType == appStopEvent )
{
Core->ReceiveCommandFromHandleEvent( 0 );
}
return true;
}
What I'm trying to do is instead of making the entire GCoreType class accessible to the HandleEvent function, i just want ONE function on the GCoreType to be accessible (along with all the public junk of course).
I know that up there is syntactically incorrect. What I want to know is if what I'm trying to do is possible.
Thanks!