fork download
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. class B
  8. {
  9. public:
  10. int b;
  11. };
  12.  
  13. class C
  14. {
  15. public:
  16. int c;
  17. };
  18.  
  19. class D: public B, public C
  20. {
  21. public:
  22. int d;
  23. };
  24.  
  25. void f1(B* b)
  26. {
  27. cout<<b->b<<endl;
  28. cout<<b<<endl;
  29. }
  30.  
  31. void f2(C* c)
  32. {
  33. cout<<c->c<<endl;
  34. cout<<c<<endl;
  35. }
  36.  
  37. int main()
  38. {
  39. D d;
  40. d.c = 1;
  41. d.b = 2;
  42. cout<<&d<<endl;
  43. f1(&d);
  44. f2(&d);
  45. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
0xffdc8b54
2
0xffdc8b54
1
0xffdc8b58