Tour and GuidedTour. GuideTour extends Tour. I create a list of these items and add them to a vector.
list = new vector<Tour>();
list->push_back(Tour("FP001", "Fun Park 3 Day Pass", 110.00));
list->push_back(Tour("BG002", "Botanical Gardens Entry Pass", 30.00));
list->push_back(GuidedTour("SK003", "Learn to Ski Adventure Tour", 240.00, "28/07/2008", "Zail S", 25));
list->push_back(Tour("OZ004", "Open Range Zoo Entry Pass", 45.00));
list->push_back(GuidedTour("AB005", "Abseiling for Beginners Tour", 120.00, "15/07/2008", "Rex P", 35));
list->push_back(GuidedTour("RA006", "White Water Rafting Tour", 200.00, "22/06/2008", "Clint R", 16));
Then I want to go thorugh this array and check the type of these Objects
void TourManager::callDisplayOnEach() {
for (vector<Tour>::iterator it = list->begin(); it != list->end(); ++it) {
if (typeid(*it) == typeid(GuidedTour)) {
cout << "Guided Tour" << "\n";
}
else {
cout << "NOT Guided Tour : " << typeid(*it).name() << "\n";
}
//(*it).display();
}
}
However it always returns NOT a Guided Tour option.