Error: Expected declaration!!!

The Compiler keeps telling me an expected declaration for return 0;
can someone help me please?!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <iostream>
#include <string>
using namespace std;

class Product
{
	private:
		string Name; //this member will hold the name of the product
		int Calories; //this will hold the calories in the product
		double Price; //this will store the price of the product
		double Weight; //this will store the weight of the product
	
	public:
		Product();
		Product(string N, int C, double P, double W);
		string GetName();
		int GetCalories();
		double GetPrice();
		double GetWeight();
		void SetName(string N);
		void SetCalories(int C);
		void SetPrice(double P);
		void SetWeight(double W);
		void Print();
				
};

	Product::Product()
	{
		Name="";
		Calories=0;
		Price=0;
		Weight=0;
	}
	Product::Product(string N, int C, double P, double W)
	{
		Name=N;
		Calories=C;
		Price=P;
		Weight=W;
	}
	void Product::Print()
	{
		cout<<"Your product: "<<Name<<" \n\t\t\t\t Calories: "<<Calories<<" \n\t\t\t\t Price: "<<Price<<" \n\t\t\t\t Weight: "<<Weight<<endl;
	}
	void Product::SetName(string N)
	{
		Name=N;
	}
	void Product::SetCalories(int C)
	{
		Calories=C;
	}
	void Product::SetPrice(double P)
	{
		Price=P;
	}
	void Product::SetWeight(double W)
	{
		Weight=W;
	}
	string Product::GetName()
	{
		return Name;
	}
	int Product::GetCalories()
	{
		return Calories;
	}
	double Product::GetPrice()
	{
		return Calories;
	}
	double Product::GetWeight()
	{
		return Weight;
	}
int main()
{

  Product milk;
  milk.SetName("milk");
  milk.SetCalories(120);
  milk.SetPrice(5.5);
  milk.SetWeight(500);

  Product cookies("cookies", 250, 5, 150);
  cout<<"The following is the information about my products\n";

  milk.Print();
  cookies.Print();

  
  if(milk.GetCalories() + cookies.GetCalories() < 1000)
    cout<<"You can combine "<<milk.GetName()<<" and "<<cookies.GetName()<<" for good health";
  else
    cout<<"You should not combine "<<milk.GetName()<<" and "<<cookies.GetName()<<" for good health";
}

	return 0;

}
Last edited on
return 0; is outside your main function. Look at your braces.
Topic archived. No new replies allowed.