#include<iostream>
using namespace std;
class Copy {
int a, b;
public:
Copy(int x, int y) {
a = x;
b = y;
cout << "\nParameterized Constructor called\n";
}
Copy(const Copy& obj) {
a = obj.a;
b = obj.b;
cout << "Copy Constructor called\n";
}
void output() {
cout << "\nNumbers :" << a << "\t" << b;
}
};
int main() {
Copy obj(10, 20);
Copy obj2(obj);
Copy obj3 = obj;
obj.output();
obj2.output();
obj3.output();
return 0;
}
Comments
Leave a comment