C
CuTe_Engineer
hii,
////i have three headers
struct activities
{
string exercises;
int time;
};
class Gymnasium
{
protected:
activities gymarray[5];
int gymlength;
public:
void set(string,int);
void getActivities(string&,int&)const;
double calories();
void print();
Gymnasium(string, int );
};
++++++++++++++++++++++++++++++++++++
struct meals
{
string food;
int portion;
};
class Nutrition
{
protected:
meals nutritionarray[5];
int nutritionLength;
public:
void set(string , int);
void getMeals(string& , int&)const;
void print();
Nutrition(string , int);
double calories();
};
+++++++++++++++++++++++++++++++++++++++
class Regime
{
public:
void set(string,int ,string,int);
void print();
Regime(string ,int,string,int);
double calories();
private:
Gymnasium exercisePlan ;
Nutrition dietPlan;
};
/////The implitation of the set function of the class Regime how
should it be
///i did this
void Regime::set(string ex,int t,string f,int p)
{
Gymnasium::set(ex,t);
Nutrition::set(f,p);
}
//////but it gives me error
//// and if i want to subtract the calories in the Gymnasium from the
calories in the Nutrition ,like
double Regime::calories()
{
int After;
After=Gymnasium::calories()- Nutrition::calories();
return After;
}
////it gives me an error that it is illegal call of non-static member
function,why ? what should i do then ??
////i have three headers
struct activities
{
string exercises;
int time;
};
class Gymnasium
{
protected:
activities gymarray[5];
int gymlength;
public:
void set(string,int);
void getActivities(string&,int&)const;
double calories();
void print();
Gymnasium(string, int );
};
++++++++++++++++++++++++++++++++++++
struct meals
{
string food;
int portion;
};
class Nutrition
{
protected:
meals nutritionarray[5];
int nutritionLength;
public:
void set(string , int);
void getMeals(string& , int&)const;
void print();
Nutrition(string , int);
double calories();
};
+++++++++++++++++++++++++++++++++++++++
class Regime
{
public:
void set(string,int ,string,int);
void print();
Regime(string ,int,string,int);
double calories();
private:
Gymnasium exercisePlan ;
Nutrition dietPlan;
};
/////The implitation of the set function of the class Regime how
should it be
///i did this
void Regime::set(string ex,int t,string f,int p)
{
Gymnasium::set(ex,t);
Nutrition::set(f,p);
}
//////but it gives me error
//// and if i want to subtract the calories in the Gymnasium from the
calories in the Nutrition ,like
double Regime::calories()
{
int After;
After=Gymnasium::calories()- Nutrition::calories();
return After;
}
////it gives me an error that it is illegal call of non-static member
function,why ? what should i do then ??