Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 15, Problem 2PP

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 assignmentoperator, 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 classis part of this Programming Project.

class Person

{

public:

Person();

Person(string theName);

Person(const Person& theObject);

string getName() const;

Person& operator = (const Person& rtSide);

friend istream& operator >>(istream& inStream,

Person& personObject);

friend ostream& operator <<(ostream& outStream,

const Person& personObject);

private:

string name;

};

Blurred answer
Students have asked these similar questions
Declare a class named Vehicle as a base class with two data members model (string) and year (int). Then, derive a class called Car as derived class with No (int).
Problem: Create a base class called Vehicle that has the manufacturer’s name (typeString), number of cylinders in the engine (type int), and the owner (type Person). Use thePerson class developed this semester. Create a class automobile that is derived fromVehicle and has additional properties: number of passengers (type int) and weight in tons(type double). Create a class Truck which is derived from Vehicle and has additionalproperties: the load capacity in tons (type double, since it may contain a fractional part)and towing capacity in tons (type double). The classes should have:• Two constructors, a default and an overloaded constructor• All appropriate accessor and mutator methods (getters and setters).• An ‘equals’ method (must conform to the Person example and the Object class ).• A ‘toString’ method• A ‘copy’ constructor• A ‘clone’ method• A ‘finalize’ method Write a driver (client/test) class that tests ALL the methods. Be sure to invoke each of the constructors, and ALL…
Define a class named Employee. This class should extend the Person class from the previous question. The class should have a constructor, which takes the name, age, employer (String) and salary (int) as parameters (in that order). The first two parameters should be passed to the constructor of the superclass and the value of the last two parameters should be stored in instance variables. The class should define the methods, getSalary which returns the salary of the employee and getEmployer which returns the name of the employer. Any methods from the previous question that need to be overridden should be overridden! Use super and instanceof as appropriate. I.e., for the following methods you should be able to call the method in the superclass for specific situations (e.g. the compareTo method in the superclass can be called if you receive anything other than an Employee, and this also holds for the equals method). The toString method only needs to append details and as such can also…

Chapter 15 Solutions

Problem Solving with C++ (10th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY