Original Post
Hi.
I asked some basic questions here on Function Pointers, a few days ago, and got some very good answers, so i was hoping that ye could help me with the following.
I have 2 classes ( called classA and classB [ cool names ehhh] )
A is defined first, then B. Considering B is defined after A, it is possible for B to have an instance of A as a member, but not possible for A to have an instance of B as a member.
My problem is that I want to be able call a m,ember function of B from inside a member function of class A.
I thought that the best way to do this would be to pass a function pointer of the function
it was something like that I was trying, but it wouldnt work. Does anyone have any ideas what I can do to get this to work.
Giant
"Only two things are infinite, the universe and human stupidity, and I''m not sure about the former." --Albert Einstein
class classA
{
public:
void CallsBFromHere( void (*Funct)() ) { Funct(); }
};
class classB
{
public:
void CallThis( ) ( cout<<"Go in here from A"; )
void (*Funct)();
private:
classA A;
};
int main()
{
classB B;
B.Funct = CallThis;
B.A.CallsBFromHere( Funct );
return 0;
}