C++: Hierarchies Purpose: Use Inheritance

Completado Publicado Nov 8, 2013 Pagado a la entrega
Completado Pagado a la entrega

Hierarchies

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

{

protected:

T* pdata;

public:

Container() { pdata = NULL; }

void init(int n)

{

pdata = new T[n];

}

~Container()

{

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.

Programación en C Programación en C# Programación en C++

Nº del proyecto: #5108893

Sobre el proyecto

1 propuesta Proyecto remoto Activo Nov 8, 2013

Adjudicado a:

vano101

A proposal has not yet been provided

$19 USD en 1 día
(478 comentarios)
6.6