little questionable about how to do this project, I\'ll take any tips or pointer
ID: 3776247 • Letter: L
Question
little questionable about how to do this project, I'll take any tips or pointers
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 in the code that follows). 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 habe a reasonable complement of constructors and accessor methods, an overloaded assignment operator, and a copy constructor. Write a driver program that tests all your methods.
The definition of the class Person follows. The implementation of the class is 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& operatgor >>(istream& inStream,
Person& personObject);
friend ostream& operator <<(ostream& outStream,
const Person& personObject);
private:
string name;
};
thanks for any help
Explanation / Answer
First of all, you need to write a base class, Vechicle, which will have three variables:
string-> manufacturer's name
int -> number of cylinders
Person -> owner
Now, create a new Class Truck, which will inherit the Vehicle class, it will contain few more variables such as the load capacity , towing capacity etc, which are specific to truck only(not to any other type of vehicle). You need to add some methods also, which will perform certain operations such as calculateMileage() etc. Apart from this you need to define the constructors & other things mentioned in the question.
Now you need to write a driver program. This will be written in the main() method. You can write a separte class having this main() method which will invoke all the methods of the Truck class.
This excercise is just to make sure you understand the concept of inheritence & how you can implement it in real world scenario.
feel free to ask if you have any doubt & want some things more clear.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.