I'm solving a problem and am near completion but am having one little problem. I'm about to show the coding that i have but i need to make name, age, and weight value returning functions as well. You'll see what i mean.

int main()
{
    Class secretType
    {
          Public :
                 void print(string, int, int, double) const;
                 void setAge(int);
                 void setName(int);
                 void setWeight(int);
                 void setHeight(double);
                 
          
                 
                 
          Private:
                  string name;
                  int age, weight;
                  double height;
          };
          
    void print(string name, int age, int weight, double height)
    {
            cout << name;
            cout << age;
            cout << weight;
            cout << double;
            name = " ";
            age = 0;
            weight = 0;
            height = 0;
    }        
    
    void setName(string name)
    {
         
         cin >> name;
         
    }    
   
   void setAge(int age)
   {
        cin >> age;
   }
   
   void setWeight(int weight)
   {
        cin >> weight;
   }

Here it is i hope the coding doesn't look all stupid and colorful.

lines 8 and 13 must have identical parameter types. Normall do not use cin in the set functions. Put all cin statements in the main() or whereever but not in the set functions. In the set functions just set the class variable to the parameter

void setName(string name)
    {
         
         this->name = name;
         
    }
This article has been dead for over six months. Start a new discussion instead.