Question 3
Consider the following class declaration:
class PersonType
{
public:
PersonType();
PersonType (string n, int id, string bd);
private:
string
name; int
ID;
string birthday;
};
Explain what is wrong with the following code fragment and write code to correct it:
int main()
{
PersonType family [20],
newBaby ("Anny Dube", 20180912, "2 Sept");
//Assume family has been
initialised for (int i = 0;
i < 20; i++)
if (family.birthday[5] == newBaby.birthday)
cout << family.name[5] << " share a birthday with "
<< newBaby.name;
return 0;
}