fork(1) download
  1. #include <iostream>
  2.  
  3. struct A
  4. {
  5. void func() { std::cout << "Hello!\n"; }
  6. };
  7.  
  8. struct B : public A
  9. {
  10. void func() { std::cout << "Goodbye!\n"; }
  11. };
  12.  
  13. int main()
  14. {
  15. B b;
  16. A *p = &b;
  17.  
  18. p->func();
  19. b.func();
  20. }
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
Hello!
Goodbye!