fork(2) download
  1. #include <vector>
  2. #include <algorithm>
  3.  
  4. class Foo;
  5.  
  6. class BaseA {
  7. protected:
  8. bool hasChild() const { return !childs_.empty(); }
  9. std::vector<Foo> childs_;
  10. };
  11.  
  12. class BaseB {
  13. protected:
  14. bool hasChild() const { return false; }
  15. };
  16.  
  17. class Foo : public BaseA, public BaseB {
  18. public:
  19. bool hasGrandChild() const {
  20. return std::any_of(childs_.begin(), childs_.end(), [](Foo const &foo) {
  21. return foo.BaseA::hasChild();
  22. });
  23. }
  24. };
  25.  
  26. int main()
  27. {
  28. Foo foo;
  29. foo.hasGrandChild();
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In lambda function:
prog.cpp:8:10: error: 'bool BaseA::hasChild() const' is protected
prog.cpp:22:7: error: within this context
stdout
Standard output is empty