typedef void (*CALLBACKFUNC) (char*);
class ClassA
{
//...//
CALLBACKFUNC CallBackFunc;
void RunCallBackFunc( char* y );
public:
void SetCallBackFunc ( CALLBACKFUNC x );
};
void ClassA::SetCallBackFunc( CALLBACKFUNC x){ CallBackFunc = x; }
void ClassA::RunCallBackFunc( char* y ){ CallBackFunc( y ); }
Class ClassB
{
//...///
public:
void DoCallBackStuff( char* z ); <-- uses members and functions
of ClassB
};
--------------------------------
ClassA ClassWantingCallBack;
ClassB ClassWithCallBack;
ClassWantingCallBack.SetCallBackFunc( DoCallBackStuff );
Thank you in advance for your input.
David
--
------------------------------------
IBERT
PO Box 4753
Glendale, CA 91222
800/347-2251
>typedef void (*CALLBACKFUNC) (char*);
If the function is a member of class ClassB, then use this
typedef void (ClassB::*CALLBACKFUNC) (char*);
To avoid cluttering the namespace, consider putting this typedef in
the definition of classA, in the public interface, of course.
Remember to prototype the existence of classB.
>void ClassA::RunCallBackFunc( char* y ){ CallBackFunc( y ); }
Member functions must be called with either of these two : .* ->*
It's good practice to call non-member functions with a star: *
To call a member function, you need to supply the object the function
must work on.
Figure the concrete syntax for yourself -- an exercise!
--
----------------------------------
Siemel B. Naran (sbn...@uiuc.edu)
----------------------------------
> Class ClassB
> {
> //...///
> public:
> void DoCallBackStuff( char* z ); <-- uses members and functions
> of ClassB
//define the above function as below:
static void DoCallBackStuff( char* z ){cout << z << endl;}
> };
--
With regards
Sriraman.R
------------------------------------------
Nothing is impossible in this world
Even the word impossible says I'm possible.
------------------------------------------
Thanks,
--
With regards
Sriram
HCL-CISCO ODC
------------------------------------------
Nothing is impossible in this world
Even the word impossible says I'm possible.
------------------------------------------