You are on page 1of 2

#include <iostream>

#include <string>

using namespace std;

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;
}

/*DeepShallowCopy(const DeepShallowCopy& obj)


{
cout<<"In Copy Constructor"<<endl;
}*/

/*DeepShallowCopy & operator = (const DeepShallowCopy& obj)


{
cout << "In Assignment"<<endl;
}*/

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;
}

You might also like