Premiado

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

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 AIRLINE0.CSV 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++

Ver mais: programming operator, programming inheritance, lab support, inheritance programming, first lab, c programming operator, c programming classes, derive, create data access layer use linq sql nhibernate, programming lab, zencart add cart remove, paypal add cart remove quantity, add cart remove zen cart, odbc driver excel iseries add use, use sign add extra fields html forms, use perl add text pdf, Inheritance, add list remove list javascript checkbox, use add text images

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

ID do Projeto: #5094917

1 freelancer está ofertando em média $15 para este trabalho

anatol1988

Предложение еще не подано

$15 USD em 1 dia
(2 Comentários)
2.2