Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //======================================
- typedef void (* MyPrintCBType)( void *myThis, int otherParam );
- //======================================
- class MyClass
- {
- public:
- // this is to be used externally a 'C' callback
- static void nicePrint_static( void *myThis, int otherParam )
- {
- // here cannot use class members (unless doing ((MyClass *)myThis)->member)
- ((MyClass *)myThis)->nicePrint( otherParam );
- }
- private:
- // for our purpose this doesn't need to be public
- void nicePrint( int otherParam )
- {
- // here can use class members
- printf( "nice !\n" );
- }
- };
- //======================================
- int main()
- {
- MyPrintCBType printFuncPtr;
- MyClass myClass;
- printFuncPtr = nicePrint_static;
- printFuncPtr( &myClass, 3 );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment