Hello guys! Here is the task : "Write another class Person having the following attributes:
1. String name
2. Integer Age
Convert an object of type Employee to person".
Now I made another class Person in which I want my entered name and age of Employee to be copied. So I did it at line 32 and 33. And then I cout at line 63. But its showing garbage value. It should display the name and age I entered for employees object.
Person& operator= ( employee &obj )
{
name = obj.name;
age = obj.age;
return *this;
}
Why you are doing this?
I think Person should have its own data members e.g name1, and age1 where the Previous entered name should be stored! And why not just write cout << bob ; in main to print out both the data members! I am getting confused because we are just using Employees data members.