#include "STDAFX.H"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class Transfer
{
protected:
string Name;
public:
void transfer();
void xfer(string);
};
class Exchange
{
protected:
string exchItems[4];
public:
void exchange();
string exchange(int);
};
class Voucher
{
protected:
string vnumber;
string company;
double amount;
public:
Voucher(string, string, double);
void displayVoucher();
};
class TravelVoucher : public Voucher, public Transfer, public Exchange
{
protected:
string expiryDate;
public:
TravelVoucher(string, string, double , string); // constructor
void displayVoucher();
void transfer(string);
string exchange(int);
};
void Voucher::displayVoucher()
{
cout << "Voucher Number = " << vnumber << endl;
cout << "Company = " << company<< endl;
cout << "Amount = " <<setprecision(2)<< fixed << amount << endl;
cout<< endl;
}
Voucher::Voucher(string Vnumber, string Company, double Amount)
{
vnumber = Vnumber;
company = Company;
amount = Amount;
}
TravelVoucher::TravelVoucher(string Vnumber,string Company, double Amount, string ExpiryDate):Voucher( Vnumber, Company, Amount)
{
expiryDate = ExpiryDate;
}
void TravelVoucher::displayVoucher()
{
cout << "Voucher Number = " << vnumber << endl;
cout << "Company = " << company<< endl;
cout << "Amount = " <<setprecision(2)<< fixed << amount << endl;
cout << "Expiry Date = " << expiryDate<< endl;
cout<< endl;
}
int main()
{
Voucher v1("T001", "SIM University",100.00);
Voucher v2("T002", "SIA Flying School",200.00);
TravelVoucher Tv1("T003", "SIM University",150.00, "12 April 2009");
TravelVoucher Tv2("T004", "Jubilee Company",250.00, "12 June 2009");
v1.displayVoucher();
v2.displayVoucher();
Tv1.displayVoucher();
Tv2.displayVoucher();
cin.ignore();
return 0;
}
i'm having problems with part of my assignment. I'm suppose to add in a function to allow the exchange an instance of the travelvoucher to any other 4 items specified under exchItems[4]. would appreciate some tips on how take data from a array and exchange it with the text in place of the value company in the instance of the travelvoucher, thanks