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