fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A { virtual ~A() = default; int a=1; };
  5. struct B { virtual ~B() = default; int b=2; };
  6. struct C : A, B { int c=3; };
  7.  
  8. void p(C* c) {
  9. B* b = c;
  10. cout << (void*)b << endl;
  11. }
  12.  
  13. void r(C& c) {
  14. B& b = c;
  15. cout << (void*)&b << endl;
  16. }
  17.  
  18. void pr(C* c) {
  19. p(c);
  20. r(*c);
  21. }
  22.  
  23. int main() {
  24. pr(nullptr);
  25. }
  26.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
0
0x10