Write the definition of a class that has the following properties: The name of t
ID: 3673593 • Letter: W
Question
Write the definition of a class that has the following properties: The name of the class is secretType. The class secretType has four member variables name of type string, age and weight of type int, and height of type double. The class secretType has the following member functions (Make each accessor function constant.) 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 set Weight-function to set the weight set Height-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. write the definition of the member functions of the Class secretType, as described in Part c.Explanation / Answer
a.
class secretType
{
Member Variables;
Member functions;
};
Here the class secretType is created and it contains the parts as member variables and member functions
b.
class secretType
{
string name;
int age,weight;
double height;
Member functions;
};
c.
class secretType
{
string name;
int age,weight;
double height;
print() { ...statements.... }
setName() { ...statements.... }
setAge() { ...statements.... }
setWeight() { ...statements.... }
setHeight() { ...statements.... }
getName() { ...statements.... }
getAge() { ...statements.... }
getWeight() { ...statements.... }
getHeight() { ...statements.... }
void secretType(string name;int age,int weight,double height)
{
string a=name;
int b=age;
int c=weight;
double d=height;
};
int main()
{
secretType t=newsecreType(string a,int b,int c,double d);
t.print();
t. setName() ;
t.setAge();
4t.setWeight();
t.setHeight();
t.getName();
t.getAge();
t.getWeight();
t.getHeight();
}
d.
1.print() shows the output the data stored in the member function with the appropriate data
2.The function mainly contains the set of statements to show when the function is executed from main function.
3. setName() shows the function to set the name of the function
4. The function mainly shows whatever the names are related to this function are executed from main function.
5. setAge() shows the function to set the age of the names in the function
6. The function mainly shows whatever the ages are related to this function are executed from main function.
7. setWeight() shows the function to set the weight of persons in the function
8. The function mainly shows whatever the weights are related to this function are executed from main function.
9. setHeight() shows the function to set the height of the persons in the function
10. The function mainly shows whatever the heights are related to this function are executed from main function.
11.getName() shows the function to display the names of the function from setName().
12. The function mainly shows whatever the names are related to this function are reading from from function setName().
13.getAge() shows the function to display the ages of the persons from the function setAge()
14. The function mainly shows whatever the ages are related to this function are reading from function setAge().
15. getWeight() shows the function to display the weights of the persons from the function setWeight().
16. The function mainly shows whatever the weights are related to this function are reading from function setWeight().
17. getHeight() shows the function to display the heights of the persons from the function setHeight().
18. The function mainly shows whatever the heights are related to this function are reading from function setHeight();
19.void secretType() shows the constructor which contains the parameters of string,age,weght,and height .
20.Hers it shows the no of parameters are four and it shows the values as zero;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.