There is a some part of code in which class is defined as Meal. The class,Meal, has a object of named total and I want to show and take input for total's attributes. I went many solutions but didn't get any proper solution. Please help me in solving this problem. I would be grateful.
void operator <<(ostream &out, Meal &ob)
{
out<<"Entree: "<<ob.entree<<endl;
out<<"Calorie: "<<ob.countCalorie<<endl;
}
void operator >>(istream &input, Meal &ob)
{
cout<<"Enter entree: ";
input>>ob.entree;
cout<<"Enter calorie: ";
input>>ob.countCalorie;
}
int main()
{
Meal *week[21], total;
string entree;
int cal;
for(int i = 0; i < 21; i++)
{
cout<<"Enter "<<i+1<<" entree: ";
cin>>entree;
cout<<"Enter "<<i+1<<" calorie: ";
cin>>cal;
week[i] = new Meal(entree,cal);
}
for(int i = 0; i < 21 ; i++)
{
total = total + week[i];
}
cout<<total;
cin>>total;
}