Engineering
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

answer
Answers: 3

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 14:10, bryneosburn
Line joining liquid phase with liquid and solid phase mixture is known as: a) liquidus b) solidus c) tie line d) none of the mentioned
Answers: 2
image
Engineering, 04.07.2019 19:10, nbunny7208
What is the chief metrological difference between measuring with a microscope and with an electronic comparator? a. the microscope is limited to small workpieces. a. the microscope is limited to small workpieces. c. the comparator can only examine one point on the workpiece. d. the microscope carries its own standard.
Answers: 1
image
Engineering, 04.07.2019 19:10, nhester3401
Agas is compressed from vi 0.3 m, p 1 bar to of v2 0.1 m3, p2--3 bar. pressure and volume are related linearly during the process. for the gas, find the work, in kj.
Answers: 2
image
Engineering, 04.07.2019 19:10, lexie223
Acircular aluminum shaft mounted in a journal is shown. the symmetric clearance gap between the shaft and journal is filled with sae 10w-30 oil at t 30°c. the shaft is caused to turn by the attached mass and cord. develop and solve a differential equation for the angular speed of the shaft as a function of time.
Answers: 2
Do you know the correct answer?
#include #include
using namespace std;

class person //user-defined string type

Questions in other subjects:

Konu
History, 20.10.2020 20:01
Konu
Physics, 20.10.2020 20:01