Calling a struct from a struct

how can I call the struct inside a struct in this program?

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


struct FoodStorage
{
	string Food;
	float weight;
	int Cal;
	int Pot;
	bool HasPreserv;
	struct Date{
		int Year;
		int Month; 
		int Day;
	};


};


void display(FoodStorage n)
{

	cout << "The food name is " << n.Food << endl;
	cout << "The weight of this item is:" << n.weight<<endl;
	cout << "The potassim in food" << n.Pot << endl;
	cout << "Calcium in food" << n.Cal << endl;
	cout << "The item preservatives y/n";
	if (n.HasPreserv == true)
	{
		cout << "Yes";
	}
	else cout << "No";

// What should I cout here?
	cout << "The expiration date" << ;

}
If I change some of that:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
struct Date{
	int Year;
	int Month; 
	int Day;
};

std::ostream & operator<< ( std::ostream & os, const Date & d );

struct FoodStorage
{
	string Food;
	float weight;
	int Cal;
	int Pot;
	bool HasPreserv;
	Date expiration;
};

void display( FoodStorage n ) {
	std::cout << n.expiration << '\n';
}

Can you fill the gaps now?
Topic archived. No new replies allowed.