OOP Question

Hello,

Suppose I have two classes:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Date
{
	public:
		// Constructor goes here
		int Day;
		int Month;
		int Year;
		// additional members
};

class Appointment
{
	public:
		// Constructor goes here
		char *Name;
		char *Description;
		int    Priority;
		void  PrintDate();
		// additional members...
};


I want the class 'Appointment' to be linked to 'Date' in such a way that I can create instances of 'Appointment' associated to instances of 'Date' and access the members of this parent instance; for example, retrieving the day of the appointment etc.
An std::map would accomplish what you are describing here: http://www.cplusplus.com/reference/map/map/

Although I'd like to point out that in real life, a date is a property of an appointment. So based on that train of thought it makes sense to give your 'Appointment' class an instance of your 'Date' class as a member.

This one comes down to how you have the rest of your program structured I guess.
@Computergeek01: I would use a multimap, not a map, in this case ;)
Topic archived. No new replies allowed.