fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Base {
  5. virtual void foo() {
  6. cout << "Base::foo()" << endl;
  7. }
  8.  
  9. virtual void bar() {
  10. cout << "Base::bar()" << endl;
  11. }
  12. };
  13.  
  14. struct Derived : public Base {
  15. void bar() override {
  16. cout << "Derived::bar()" << endl;
  17. Base::bar();
  18. }
  19. };
  20.  
  21. int main() {
  22. Derived d;
  23. d.foo();
  24. d.bar();
  25. return 0;
  26. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Base::foo()
Derived::bar()
Base::bar()