ツアーとガイド付きツアー。ガイド付きツアーは、ツアー クラスを拡張します。ツアー クラスで << および >> 演算子をオーバーロードしています。
私のツアークラスは次のようになります
#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];
}
オブジェクトがガイド付きツアーであっても、ツアーで指定されていることは常に行います。
助けていただけますか?