Professional Documents
Culture Documents
#include <string>
class DeepShallowCopy
{
private:
std::string first_name;
std::string last_name;
//int *age;
public:
DeepShallowCopy(){}
//DeepShallowCopy(std::string str1, std::string str2, int age1)
DeepShallowCopy(std::string str1, std::string str2)
{
first_name = str1;
last_name = str2;
//age = new int();
//*age = age1;
}
void SetValues()
{
first_name = "Rolta";
last_name = "India";
//*age = 90;
}
void Display()
{
cout<<first_name<<endl;
cout<<last_name<<endl;
//cout<<age<<endl;
}
};
int main()
{
DeepShallowCopy obj1("ashima","Gupta");
DeepShallowCopy *obj2 = &obj1;
obj1.Display();
obj2->Display();
obj2->SetValues();
obj1.Display();
obj2->Display();
return 0;
}