fork download
  1. typedef void (*FuncPtr)(void*);
  2.  
  3. class MyClass
  4. {
  5. public:
  6.  
  7. void Method ();
  8.  
  9. //
  10. // More callback thunks and methods...
  11. //
  12.  
  13. MyClass ()
  14. {
  15. // RegisterCallbacks(s_callbackTable, this);
  16. }
  17.  
  18. private:
  19.  
  20. static void Thunk (void* context)
  21. {
  22. reinterpret_cast<MyClass*>(context)->Method();
  23. }
  24.  
  25. static const FuncPtr s_callbackTable[];
  26. };
  27.  
  28. //
  29. // In the .cpp file:
  30. //
  31. const FuncPtr MyClass::s_callbackTable[] =
  32. {
  33. &MyClass::Thunk
  34. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
/home/1SclTh/ccCasXY0.o: In function `MyClass::Thunk(void*)':
prog.cpp:(.text._ZN7MyClass5ThunkEPv[_ZN7MyClass5ThunkEPv]+0x1): undefined reference to `MyClass::Method()'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty