#include
#include
using namespace std;
class person //user-defined string type
{
private:
char* str; //pointer to string
public:
person(char* s) //constructor, one arg
{
int length = strlen(s); //length of string argument
str = new char[length+1]; //get memory
strcpy_s(str, length+1, s); //copy argument to it
}
~person() //destructor
{
cout << "Deleting str.\n";
delete[] str; //release memory
}
void dspName() //display the String
{
cout << "name: " << str << endl;
}
};
int main()
{
char str [] = "El chapo";
char* pstr = str;
person s1 (pstr);
s1.display(); //display string
return 0;
}
Modify the person class above to include the person’s age.
Modify the one-argument constructor to accept a new argument, the person’s age.
Implement a function or modify the existing one to display the person’s age.
Display the person’s name and age in a readable format