Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the definition of a class that has the following properties: a. The name o

ID: 3767281 • Letter: W

Question

Write the definition of a class that has the following properties:

a. The name of the class is secretType.

b. The class secretType has four member variables: name of type string, age and weight of type int, and height of type double.

c. 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

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.

d. Write the definition of the member functions of the class secretType, as described in Part c.

answer in C++ will rate and provide feedback, please label answers seperately, thank you

Explanation / Answer

#include<iostream.h>
#include<conio.h>
#include<string.h>
class secretType
{
public:
   char name[20];
   int age, weight;
   double height;

   secretType()
   {
       strcpy(name," ");
       age=0;
       weight=0;
       height=0;
   }
   void print()
   {
       cout<<" Name:"<<name;
       cout<<" Age:"<<age;
       cout<<" weight:"<<weight;
       cout<<" Height:"<<height;
   }

   void setName(char n[])
   {
       strcpy(name,n);
   }
   void setAge(int a)
   {
       age=a;
   }

   void setWeight(int w)
   {
       weight=w;
   }
   void setHeight(double h)
   {
       height=h;
   }
   char* getName()
   {
       return name;
   }
   int getAge()
   {
       return age;
   }

   int getWeight()
   {
       return weight;
   }
   double getHeight()
   {
       return height;
   }

};

void main()
{
   secretType o;
   o.setName("aaa");
   o.setAge(10);
   o.setWeight(50);
   o.setHeight(5);
   char n[20];
   strcpy(n,o.getName());
   int a=o.getAge();
   int w=o.getWeight();
   double h=o.getHeight();

   o.print();
   getch();
}