I am looking for something like a school time table. Based on two input – Day of the week and Time of the day, one decides the subject. To implement this in c++, I was thinking of something like “map < pair < int, int>, int>”.
I was reading here to use a key class and operator overloading.
Is there any other elegant way of doing it?
Thanks in Advance
That’s not a map with two keys (which would allow you to look up items from knowledge of just one key), it’s a composite key, and
map<pair<day, time>, subject>should work just fine.Also consider
map<day, map<time, subject>>.