fork download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. int val;
  6. public:
  7. void foo() {std::cout << "foo\n";}
  8. void bar() {std::cout << "bar\n";}
  9. };
  10.  
  11. int main()
  12. {
  13. A *pA;
  14. pA->foo();
  15. pA->bar();
  16.  
  17. void *ptr = nullptr;
  18. static_cast<A*> (ptr)->foo();
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
foo
bar
foo