fork download
  1. #include <cstdio>
  2.  
  3. class Base1 {
  4. public:
  5. int func1() { return var1 = 1; }
  6. int var1;
  7. };
  8.  
  9. class Base2 {
  10. public:
  11. int func2() { return var2 = 2; }
  12. int var2;
  13. };
  14.  
  15. class Derived : public Base1, public Base2 {
  16. public:
  17. int func() { return var = func1() + func2(); }
  18. int var;
  19. };
  20.  
  21. int main() {
  22. Derived o;
  23. std::printf("%d %d %d\n", o.func1(), o.func2(), o.func());
  24. std::printf("%d %d %d %p %p %p\n", o.var1, o.var2, o.var, &o.var1, &o.var2, &o.var);
  25. std::printf("%p %p %p\n", &o, static_cast<Base1*>(&o), static_cast<Base2*>(&o));
  26. return 0;
  27. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
1 2 3
1 2 3 0xbfff3254 0xbfff3258 0xbfff325c
0xbfff3254 0xbfff3254 0xbfff3258