fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. public:
  7. A() {
  8. //init(this);
  9. };
  10. virtual void func()=0;
  11. private:
  12. void init(A *pA) {
  13. pA->func();
  14. }
  15. };
  16.  
  17. void A::func() {
  18. cout<<"A::func"<<endl;
  19. }
  20.  
  21. class B : public A
  22. {
  23. public:
  24. virtual void func(){
  25. cout<<"B::func"<<endl;
  26. A::func();
  27. };
  28. };
  29.  
  30.  
  31.  
  32. int main() {
  33. // your code goes here
  34. A * a = new B;
  35. a->func();
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
B::func
A::func