fork download
  1. #include <iostream>
  2.  
  3. class Base {
  4. public:
  5. Base(int foo_val):
  6. foo(foo_val)
  7. {
  8. ;
  9. }
  10.  
  11. protected:
  12. int getfoo() const { return foo; }
  13.  
  14. private:
  15. const int foo;
  16. };
  17.  
  18. class Derived : Base {
  19. public:
  20. Derived(): Base(10) { ; }
  21.  
  22. void Display(std::ostream& out) const {
  23. out << getfoo();
  24. }
  25. };
  26.  
  27. int main() {
  28. Derived d;
  29. d.Display(std::cout);
  30. return 0;
  31. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
10