fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class B { public: int x; };
  5. class A: public B {};
  6.  
  7. void foo(const B& b)
  8. {
  9. cout << "Hello world: " << b.x << endl;
  10. }
  11.  
  12. int main()
  13. {
  14. A a;
  15. a.x = 30;
  16.  
  17. foo(a);
  18. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Hello world: 30