C++: Hierarchies Purpose: Use Inheritance


Purpose: Use Inheritance

Modify lab #2 as follows:

* 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.

* Your converted code must compile using Visual Studio. If you’re not using Visual Studio, make sure your source compiles in the computer lab using Visual Studio. Source code that is submitted but does not compile will not be graded.

Habilidades: Programação C, Programação C#, Programação C++

Veja mais: visual programming c++, template container, programming operator, programming inheritance, programming concepts, lab support, inheritance programming, first lab, first computer programming, does c have classes, c sharp base, c programming template, c programming operator, c# programming concepts, c programming classes, container template, containers c, container programming, container in c, computer programming concepts, computer programming classes, computer programming class, computer programming c++, c containers, c computer programming

Acerca do Empregador:
( 14 comentários ) New york, United States

ID do Projeto: #5108893

Concedido a:


A proposal has not yet been provided

$19 USD em 1 dia
(478 Comentários)