//
// main.cpp
// Labtask4_2
//
// Created by go jialun on 12/09/2015.
// Copyright (c) 2015 go jialun. All rights reserved.
//
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
class Meal{
friend ostream & operator<<(ostream&, const Meal&);
friend istream & operator>>(istream&, Meal&);
private:
string name;
double calories;
double dailytotal;
public:
Meal();
Meal(string,double);
Meal operator+(Meal);
};
Meal::Meal(){
name = "None";
calories = 0.00;
dailytotal = 0.00;
}
Meal::Meal(string n, double c){
name = n;
calories = c;
}
Meal Meal::operator+(Meal m){
Meal meal;
meal.dailytotal = calories + m.calories;
return meal;
}
ostream & operator<<(ostream & output, const Meal & m){
cout<<"Names: "<<m.name<<endl;
cout<<"Calories: "<<m.calories<<endl;
return output;
}
istream & operator>>(istream & input, Meal & m){
cout<<"Name: ";
input>>m.name;
cout<<"Calories: ";
input>>m.calories;
return input;
}
int main(){
Meal m,x,z;
cout<<"First Person"<<endl;
cin>>m;
cout<<"Second Person"<<endl;
cin>>x;
cout<<"Both Calories"<<endl;
cout<<m;
cout<<x;
cout<<"Total Daily Calories"<<endl;
z= m+x;
cout<<z;
return 0;
}
I am new in C++ and I really can't figure out why the program cannot run...
KINDLY PLEASE SAVE ME =(
Thanks ya...I have figured out...