fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. public:
  7. A(const string& str) : text(str) { }
  8. ~A() { }
  9. string getText(){ return this->text; }
  10. private:
  11. string text;
  12. };
  13.  
  14.  
  15. class B
  16. {
  17. public:
  18. B(const string& str) : x(A(str)) { }
  19. ~B() { }
  20. string getObjAClassText() { return this->x.getText(); }
  21. private:
  22. A x;
  23. };
  24.  
  25. int main() {
  26. B obj("test");
  27. cout << obj.getObjAClassText() << endl;
  28. return 0;
  29. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
test