fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Base {
  5. public:
  6. void display() {
  7. foo();
  8. }
  9. virtual void foo() {
  10. cout << "Base.foo()" << endl;
  11. }
  12. };
  13.  
  14. class Derived : public Base {
  15. public:
  16. void foo() {
  17. cout << "Derived.foo()" << endl;
  18. }
  19. };
  20.  
  21. int main() {
  22. Derived* derived = new Derived();
  23. derived->display();
  24. }
  25.  
Success #stdin #stdout 0.01s 3460KB
stdin
Standard input is empty
stdout
Derived.foo()