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 15:10
If you were designing a bumper for a car, would you prefer it to exhibit elastic or plastic deformation? why? consider the functions of a bumper in both a minor "fender-bender" and a major collision.
Answers: 1
question
Engineering, 04.07.2019 18:10
Acompressor receives the shaft work to decrease the pressure of the fluid. a)- true b)- false
Answers: 3
question
Engineering, 04.07.2019 18:10
Coiled springs ought to be very strong and stiff. si3n4 is a strong, stiff material. would you select this material for a spring? explain.
Answers: 2
question
Engineering, 04.07.2019 18:10
Which from the following instrument is commonly used to detect the high pitch butzing sound in bearings? [clo4] a)-digital ultrasonic meter b)-infrared camera c)-spectroscopic d)-vibrometer
Answers: 2
You know the right answer?
#include #include
using namespace std;

class person //user-defined string type
Questions
question
Computers and Technology, 22.08.2019 07:50
question
Social Studies, 22.08.2019 07:50
question
Geography, 22.08.2019 07:50
Questions on the website: 13722359