fork(193) download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. class Derived;
  5.  
  6. class Base {
  7. private:
  8. virtual void fun() { cout << "Base Fun"; }
  9. friend int main();
  10. };
  11.  
  12. class Derived: public Base {
  13. public:
  14. void fun() { cout << "Derived Fun"; }
  15. };
  16.  
  17. int main()
  18. {
  19. Base *ptr = new Derived;
  20. ptr->fun();
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
Derived Fun