Hey everyone! I was recently assigned this program in class and have only finished about half the work but am already very confused. I was just hoping that some of you could give it a shot and share what kind of code you came up with. Well here it is any help would be very appreciative.

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 instructions). 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 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 (as stated above) is below. The implementation of the class is part of this programming assignment.

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;

};

Again thanks to anyone who might be able to give me a hand!

Recommended Answers

All 2 Replies

You didn't ask a question, all you did was post the assignment.

Step 1.
It's a base class because you're going to be deriving other classes from it.

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 instructions).

Step 2.
Derive a class from the base you just made using C++'s inheritance features.

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 and accessor methods, an overloaded assignment operator, and a copy constructor.
It's also probably safe to assume a "property" is a variable.

Step 3.
A driver program is a simple program that tests to make sure everything is working as it should be. Which means you will be testing your class member functions, just make sure they produce the right output. If you made a good driver that provides a description of the test being performed and it's result like "SUCCESS" or "FAILURE" I think you will get good marks.

Write a driver program that tests all your methods.

-----------------------------------------------------------------------------------
If you have any actual questions for us, please do let us know.
http://www.cplusplus.com/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.