Use Inheritance

Modify lab #2 as follows: (the Previous lab)

* Create a new class called 'Person'. This class contains only the 'person' data from the previous ‘Passenger’ (i.e. the first and last names).

* Derive the Passenger class from the person class, and remove any person data from the passenger class.

class Passenger : public Person



* Add any support functions as necessary to the Person and Passenger classes. This includes copy constructors, operator = and operator <<.

* You may have noticed that the previous assignments use the concepts of containers. A row is a container of seats. A section is a container of rows. An airline is a container of sections. Add a new template class as follows to act as a container:

template <typename T>

class Container



T* pdata;


Container() { pdata = NULL; }

void init(int n)


pdata = new T[n];




delete [] pdata;


void set(T data,int x)


pdata[x] = data;


T& get(int x)


return pdata[x];



* Derive the Row class from the Container. Remove the Seat* and replace it with the Container base class.

class Row : public Container<Seat>


Seat* seats; // remove

* Derive the Section class from the Container. Remove the Row* and replace it with the Container base class.

class Section : public Container<Row>


Row* rows; // remove

* Derive the Airline class from the Container. Remove the Section* and replace it with the Container base class.

class Airline : public Container<Section>


Section* sections; // remove

* Read and process the [url removed, login to view] file like previous lab assignments.

* Use MemTracker to track your memory usage.

Habilidades: Programação C++

Veja mais: template container, lab support, first lab, container template, derive, airline data, read process memory, seats process, create csv file template, template airline, init, read data base file, public usage, modify csv file, memory usage, airline template, remove read, use case diagram airline reservation, delete airline, modify delete set null, use add section button, joomla section resources key concepts, process create csv file, sql server use stored procedure copy data, file last names

Acerca do Empregador:
( 43 comentários ) san jose, United States

ID do Projeto: #5106615

Concedido a:


Hired by the Employer

$15 USD em 5 dias
(4 Comentários)