Accessing A Classes Member Variables Nested Inside Another Class

I have two classes, a Package class and a Person class. The Package class has two Person objects has member variables, a Sender and a Receiver. While overloading the << operator for the Package class so that it will make an output label from everything in the Package class. Here is my code...

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
class Package{
public:
	Person Sender;
	Person Reciever;
	int weight;
	double cost;
	friend ostream &operator<<(ostream &out, Package &pack);
};

class Person{
public:
	string getName(){return name;}
	void setName(string n){name = n;}
	string getAddress(){return address;}
	void setAddress(string a){address = a;}
	string getCity(){return city;}
	void setCity(string c){city = c;}
	string getState(){return state;}
	void setState(string s){state = s;}
	string getZip(){return zipCode;}
	void setZip(string z){zipCode = z;}

private:
	string name;
	string address;
	string city;
	string state;
	string zipCode;

};

ostream &operator<<(ostream &out, Package &pack){
	
	out << setw(15) << "Regular Package:";
	out << endl;
	out << setw(15) << "Sender Info:";
	out << setw(20) << "Full Name" << setw(25) << "Addresss" << setw(10) << "City" << setw(10) << "Zip Code";
	out << setw(20) << "_________" << setw(25) << "________" << setw(10) << "____" << setw(10) << "________";
	out << setw(20) << Sender.getName() << setw(25) << Sender.getAddress() << setw(10) << Sender.getCity() << setw(10) << Sender.getZip();

	return out;
}


So my problem is on that last output line, I am unable to call Sender.getName()... etc. Is there a proper syntax so that I can access the members of the Person class while overloading the << operator for the Package class? Hopefully that made sense and appreciate any help that you can throw my way.
pack.Sender.getName()
Thank you, it was so simple I didn't even think of it.
Topic archived. No new replies allowed.