fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Vector
  5. {
  6. public:
  7. Vector(int a, int b)
  8. {
  9. x = a;
  10. y = b;
  11. }
  12. void wrt()
  13. {
  14. cout<<"x = " << x << " y = " << y << endl;
  15. }
  16. void set(int a, int b)
  17. {
  18. x = a;
  19. y = b;
  20. }
  21. private:
  22. int x, y;
  23. };
  24.  
  25. int main() {
  26. Vector a(10, 10);
  27. Vector* b = &a;
  28. Vector c = *b;
  29. a.set(20, 20);
  30. a.wrt();
  31. c.wrt();
  32. return 0;
  33. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
x = 20 y = 20
x = 10 y = 10