SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
Inheritance
Exercise:
Programming Projects
Question:4 | ISBN:9780321531346 | Edition: 7

Question

Create a base class called Vehicle that has the manufacturer’s name (type

string), number of cylinders in the engine (type int), and owner (type

Person, given below). Then create a class called Truck that is derived from Vehicle and has additional properties: the load capacity in tons (type double since it may contain a fractional part) and towing capacity in pounds (type int). Be sure your classes have a reasonable complement of constructors, accessor, and mutator member functions, an overloaded assignment operator, and a copy constructor. Write a driver program that tests all your member functions.

The definition of the class Person follows. The implementation of the

class is part of this Programming Project.

class Person

{

public:

Person();

Person(string the_name);

Person(const Person& the_object);

string get_name() const;

Person& operator=(const Person& rt_side);

friend istream& operator >>(istream& in_stream,

Person& person_object);

friend ostream& operator <<(ostream& out_stream,

const Person& person_object);

private:

string name;

};

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.