fork(2) download
  1.  
  2. #include <iostream>
  3.  
  4. struct something
  5. {
  6. int n;
  7. void print() { std::cout << n << std::endl; }
  8. };
  9.  
  10.  
  11. int main()
  12. {
  13. something s1 = { 123 };
  14.  
  15. union
  16. {
  17. void (something::*memfun)();
  18. void (*print)( something& );
  19. };
  20.  
  21. memfun = &something::print;
  22. print(s1);
  23. }
  24.  
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
123