fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class IParent
  5. {
  6. public:
  7.  
  8. virtual void foo( ) = 0;
  9. };
  10.  
  11. class Root : private IParent {
  12. private:
  13. virtual void foo( ) override { cout << "foo!"; }
  14. };
  15.  
  16. class Test {
  17. public:
  18. Test( IParent& p ) : m_parent(p) {
  19. m_parent.foo(); // Wieso kann ich hier eine private Methode von Root aufrufen?
  20. }
  21. private:
  22. IParent& m_parent;
  23. };
  24.  
  25. int main()
  26. {
  27. //Ausgeführter Code:
  28. Root root;
  29. Test t( root );
  30. }
Compilation error #stdin compilation error #stdout 0s 15232KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:29:16: error: ‘IParent’ is an inaccessible base of ‘Root’
   Test t( root );
                ^
stdout
Standard output is empty