class person
{
private:
string p_name;
int p_age;
public:
person(string name, int age){
p_name = name;
p_age = age;
}
person(const person &pers){
p_name = pers.p_name;
p_age = pers.p_age;
}
void print(){
cout << "Name: " << p_name << '\n';
cout << "Age: " << p_age << '\n';
cout << &p_age << '\n';
cout << '\n';
}
};
int main()
{
person obj1{"Name", 18};
obj1.print();
person obj2{obj1};
obj2.print();
return 0;
}
Here's my code, it works, but when i delete copy constructor in still works, so what is a point to use copy constructor?