fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct parent {
  5. int type_ = 0;
  6. parent(int type):type_(type) {}
  7. };
  8.  
  9. struct child: parent {
  10. child():parent(1) {}
  11. };
  12.  
  13. int main() {
  14. child ch;
  15. printf("parent %p\r\n", &static_cast<parent&>(ch).type_);
  16. printf("child %p\r\n", &static_cast<child&>(ch).type_);
  17. return 0;
  18. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
parent 0xbfda0e1c
child 0xbfda0e1c