fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. class Test
  5. {
  6. private:
  7. int x;
  8. public:
  9. Test(int x = 0) { this->x = x; }
  10. void change(Test *t)
  11. {// this = t;
  12. Test * p = t;
  13. }
  14. void print() { cout << "x = " << x << endl; }
  15. };
  16.  
  17. int main()
  18. {
  19. Test obj(5);
  20. Test *ptr = new Test (10);
  21. obj.change(ptr);
  22. obj.print();
  23. return 0;
  24. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
x = 5