fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A {protected: double x,y;
  5. public:virtual void show(){cout << x+y << endl;}
  6. A(double x=1, double y=2){A::x=x;A::y=y;}};
  7.  
  8. class B: public A {protected: int x,y;
  9. public:void show(){cout << x-y << endl;}
  10. B(int x=3, int y=4){B::x=x;B::y=y;}};
  11.  
  12. class C: public B {unsigned x,y;
  13. public: void show(){cout << x*y << endl;}
  14. C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
  15.  
  16. int main()
  17. { A a, *p; B b; C c;
  18. (p=&b)->show();
  19. return 0; }
  20.  
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
-1