fork(5) download
  1. #include <iostream>
  2.  
  3. class A {
  4. public:
  5. A() {}
  6. virtual ~A() {}
  7.  
  8. virtual void runFn() {GetPart(); }
  9.  
  10. private:
  11. virtual void GetPart() = 0;
  12. };
  13.  
  14. class B : public A {
  15. public:
  16. B() {}
  17. virtual ~B() {}
  18. private:
  19. virtual void GetPart() override {
  20. // This line would not compile
  21. A::GetPart();
  22. std::cout << "GETPART RUN" << std::endl;
  23. }
  24. };
  25.  
  26. int main()
  27. {
  28. B b;
  29. b.runFn();
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 15240KB
stdin
Standard input is empty
compilation info
prog.cpp:21:9: error: 'GetPart' is a private member of 'A'
            A::GetPart();
               ^
prog.cpp:11:15: note: declared private here
        virtual void GetPart() = 0;
                     ^
1 error generated.
stdout
Standard output is empty