subject
Engineering, 10.12.2020 09:20 josht7806

#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

ansver
Answers: 3

Another question on Engineering

question
Engineering, 03.07.2019 14:10
The y form of iron is known as: a) ferrite b) cementite c) perlite d) austenite
Answers: 3
question
Engineering, 04.07.2019 18:10
Different types of steels contain different elements that alter the characteristics of the steel. for each of the following elements, explain what the element does when alloyed with steel.
Answers: 2
question
Engineering, 04.07.2019 18:10
Calculate the bore of a cylinder that has a stroke of 18 inches and an extension time of 6 seconds at a flow rate of 4 gal/min.
Answers: 3
question
Engineering, 04.07.2019 19:10
In general, how do thermosetting plastics compare to thermoplastics in mechanical and physical properties?
Answers: 3
You know the right answer?
#include #include
using namespace std;

class person //user-defined string type
Questions
question
Mathematics, 26.09.2019 05:10
question
Mathematics, 26.09.2019 05:10
question
Biology, 26.09.2019 05:10
question
Mathematics, 26.09.2019 05:10