fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Point {
  5. int x, y;
  6. public:
  7. Point(int i = 0, int j = 0);
  8. Point(const Point &t);
  9. };
  10. Point::Point(int i, int j) {
  11. x = i, y = j;
  12. cout <<"Normal Constructor called\n";
  13. }
  14. Point::Point(const Point &t) {
  15. y = t.y;
  16. cout <<"Copy Constructor called\n";
  17. }
  18. int main(){
  19. Point *t1, *t2;
  20. t1 = new Point(10, 15);
  21. t2 = new Point(*t1);
  22. Point t3 = *t1;
  23. Point t4;
  24. t4 = t3;
  25. return 0;
  26.  
  27. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Normal Constructor called
Copy Constructor called
Copy Constructor called
Normal Constructor called