fork(2) download
  1. #include <vector>
  2. #include <algorithm>
  3.  
  4. class Foo;
  5.  
  6. class Base {
  7. protected:
  8. bool hasChild() const { return !childs_.empty(); }
  9. std::vector<Foo> childs_;
  10. };
  11.  
  12. class Foo : public Base {
  13. public:
  14. bool hasGrandChild() const {
  15. return std::any_of(childs_.begin(), childs_.end(), [](Foo const &foo) {
  16. return foo.Base::hasChild();
  17. });
  18. }
  19. };
  20.  
  21. int main()
  22. {
  23. Foo foo;
  24. foo.hasGrandChild();
  25. return 0;
  26. }
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 Base::hasChild() const' is protected
prog.cpp:17:7: error: within this context
stdout
Standard output is empty