Em Andamento

C++: Hierarchies Purpose: Use Inheritance

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.

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

Ver mais: template container, programming inheritance, programming concepts, lab support, inheritance programming, first lab, first computer programming, sharp base, programming operator, container template, containers c, container programming, computer programming concepts, c containers, derive, airline data, read process memory, 2013 visual studio add, visual studio csv, airline seat code, visual studio 2013 add, visual studio sharp, visual studio add 2013, sharp visual studio, seats process

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

ID do Projeto: #5108893

Premiar a:

vano101

A proposal has not yet been provided

$19 USD em 1 dia
(478 Avaliações)
6.6