Оператор перегрузки в подклассе
тур и экскурсия. Экскурсия продлевает тур класс. Я перегружаю операторов << и >> в классе тура.
Мой тур класс выглядит
#include <iostream>
#include <vector>
#include "Customer.h"
using namespace std;
class Tour {
protected:
string id;
string description;
double fee;
vector<string> customerList;
public:
Tour();
Tour(string idVal, string descriptionVal, double feeVal);
string getId();
string getDescription();
double getFee();
double getTotalForTour();
virtual void addCustomer(string cust);
vector<string> getCustomers();
virtual void display();
friend ostream& operator<< (ostream &out, Tour &cust);
friend istream& operator>> (istream &in, Tour &cust);
};
тогда моя экскурсия выглядит так,
#include <iostream>
#include "Tour.h"
#include "SimpleDate.h"
using namespace std;
class GuidedTour : public Tour {
private:
SimpleDate* date;
string guideName;
int maxNumTourists;
public:
GuidedTour();
GuidedTour(string idVal, string descriptionVal, double feeVal, SimpleDate* dateVal, string guideNameVal, int maxNumTouristsVal);
virtual void addCustomer(string cust);
SimpleDate* getDate();
void display();
friend ostream& operator<< (ostream &out, GuidedTour &cust);
friend istream& operator>> (istream &in, GuidedTour &cust);
};
Я хочу по-разному перегрузить эти операторы в подклассе, чтобы сделать что-то еще.
У меня есть Вектор, который содержит туры и экскурсии.
Когда я перебираю вектор и делаю следующее,
for (unsigned int i = 0; i < tourListVector.size(); i++) {
cout << *tourListVector[i];
}
Он всегда выполняет то, что указано в туре, даже если объект является экскурсией.
Можете ли вы помочь?