fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. extern "C"
  5. class Test1 {
  6. public:
  7. static void foo(int a)
  8. {
  9. cout << "foo called with " << a << endl;
  10. }
  11. };
  12.  
  13. class Test {
  14. public:
  15. static void foo(int a) noexcept
  16. {
  17. cout << "foo called with " << a << endl;
  18. }
  19. };
  20.  
  21.  
  22. extern "C" void bar(void (*fp)(int))
  23. {
  24. fp(42);
  25. }
  26.  
  27. int main() {
  28. bar(Test1::foo);
  29. bar(Test::foo);
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 4244KB
stdin
Standard input is empty
stdout
foo called with 42
foo called with 42