[prog] C++ STL Problem

Noir acknak_halflife at yahoo.co.uk
Sun Oct 24 05:54:24 EST 2004

I am working on a Aeroplane.cpp file where it asks to "make a PassengerList 
supported by GenericList template." I am utterly confused as to what I 
should do in regards to this. I have made my cpp file which also asks me to 
make a custom constructor, a copy constructor to perform deep copy, a 
destructor and a display method (I think I have done all these). The only 
problem is with the GenericList template.


#include "TemplateList.h"
typedef GenericList <Passenger,5>PassengerList;
typedef GenericList <Luggage,20>LuggageList;

using namespace std;

class Aeroplane
                 string fBrand;
                 string fModel;
	      PassengerList *myPassengers;
                 LuggageList   *myLuggage;
                 Aeroplane(const string Brand, const string Model,
                 PassengerList *Passengers, LuggageList *Luggage);
                 Aeroplane(const Aeroplane& src);
                 void Display();
#endif // AEROPLANE_H


#include <string>
#include "Aeroplane.h"

using namespace std;
Aeroplane::Aeroplane (const string Brand, const string Model, PassengerList 
					  LuggageList *Luggage) {
	this->myPassengers = new PassengerList (*Passengers);
	this->myLuggage = new LuggageList (*Luggage);

Aeroplane::Aeroplane (const Aeroplane& src) : fbrand(src.fBrand), 
fModel(src.fModel) {
	this->myPassengers = new PassengerList (*src.myPassengers);
	//might cause problem later. If so, comment out+compile and see
	this->myLuggage = new LuggageList (*src.myLuggage);

	delete this->myPassengers;
	delete this->myLuggage;

void Aeroplane::Display()
	cout << this->fBrand << "" << this->fModel <<endl;
//	myPassengers->Display;

More information about the Programming mailing list