fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Base {
  5. protected:
  6. static void call_foo(Base* base) { base->foo(); }
  7. private:
  8. virtual void foo() = 0;
  9. };
  10.  
  11. class Derived : public Base {
  12. private:
  13. Base *b;
  14. protected:
  15. virtual void foo() { /* Some implementation */ };
  16. virtual void foo2() {
  17. // b->foo(); // doesn't work
  18. call_foo(b); // works
  19. }
  20. };
  21.  
  22. int main() {
  23. // your code goes here
  24. return 0;
  25. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty