Question: Write a c++ program to d esign and Implement a class called personType
ID: 3677865 • Letter: Q
Question
Question: Write a c++ program to design and Implement a class called personType the following properties:
a. The class personType has four member variables: name (string), age (int), weight (double), height (double)
b. The class personType has the following member functions. (Make each accessor function constant. Can you figure out which functions areaccessor functions?)
print— outputs the data stored in the member variables with the appropriate titles
setName— function to set the name
setAge— function to set the age
setWeight— function to set the weight
setHeight— function to set the height
getName— value- returning function to return the name
getAge— value- returning function to return the age
getWeight— value- returning function to return the weight
getHeight— value- returning function to return the height
constructor— with default parameters: The default value of name is the empty string "", and the default values of age, weight, and height are 0.
Explanation / Answer
//secretType class is personType #include using namespace std; class secretType { public: // constructor with parameters secretType secretObject(string = " ", int = 0, int = 0, double = 0); void print() const; //prints for testing void setName(string name); void setAge(int age); void setWeight(int weight); void setHeight(double height); string getName()const; int getAge()const; int getWeight()const; double getHeight()const; private: string name; int age, weight; double height; }; // class member function definitions void secretType::print() const { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.