fork download
  1. #include <iostream>
  2. struct FooBar {
  3. virtual void Foo() = 0;
  4. virtual void Bar() = 0;
  5. };
  6.  
  7. class foo : public FooBar {
  8. public:
  9. void Foo() override {
  10. std::cout << "foo::Foo" << std::endl;
  11. }
  12. void Bar() override {
  13. Foo();
  14. std::cout << "foo::Bar" << std::endl;
  15. }
  16. };
  17.  
  18. class bar : public foo {
  19. public:
  20. void Foo() override {
  21. std::cout << "bar::Foo" << std::endl;
  22. }
  23. };
  24.  
  25. int main() {
  26. FooBar* fb = new bar();
  27. fb->Bar();
  28. delete fb;
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
bar::Foo
foo::Bar