fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Base
  5. {
  6. public:
  7. int b;
  8. };
  9.  
  10. class Derived : public Base
  11. {
  12. public:
  13. int d;
  14. };
  15.  
  16. int main() {
  17. Derived d;
  18. d.b = 1;
  19. d.d = 2;
  20. Derived e(d);
  21. std::cout << "e.b=" << e.b
  22. << "e.d=" << e.d << std::endl;
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 15224KB
stdin
Standard input is empty
stdout
e.b=1e.d=2