fork download
  1. #include <iostream>
  2.  
  3. class Father
  4. {
  5. protected:
  6. int m_value = 42;
  7. };
  8.  
  9. class Mother
  10. {
  11. public:
  12. virtual void foo() = 0;
  13. };
  14.  
  15. class Daughter : public Father, public Mother
  16. {
  17. public:
  18. void foo() override;
  19. };
  20.  
  21. void Daughter::foo()
  22. {
  23. std::cout << m_value << std::endl;
  24. }
  25.  
  26. int main()
  27. {
  28. Daughter d;
  29. Mother& m = d;
  30. d.foo();
  31. m.foo();
  32. }
  33.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
42
42