View the step-by-step solution to:

Consider the following class: class Computer { public:

Consider the following class: class Computer { public: Computer(); Computer(int s, int mm, int hm); void display_specs(ostream & out)const; int get_speed()const; int get_mmemory()const; int get_hmemory()const; private: int speed; int main_memory; int harddisk_memory; };

(a) Implement class Computer.

(b) Test class Computer in a driver program that does the following:

 instantiates an object of class Computer, with the following details:

speed: 1600

main memory: 4

hard disk: 16

 use the accessor functions to display the specifications of the instantiated object on the console

 display the specifications of the instantiated object on the console with the member function display_specs().

(c) Derive and implement a class Laptop from class Computer. This class has additional member variables, battery_time and weight. Class Laptop also has an overloaded constructor and member functions, get_battime() and get_weight()to return member variables battery_time and weight respectively. The class Laptop should override function display_specs() in order to display the member variables of Laptop.

Implement the overloaded constructor for the class Laptop by invoking the base class constructor.

(d) Test class Laptop in a driver program that does the following:

 instantiates an object of class Laptop, with the following details:

speed: 1333

main memory: 2

hard disk: 8

battery time: 8

weight: 1.25

 use the accessor functions to display the specifications of the instantiated object on the console.

Top Answer

Sample Output: Speed: 1600 Main memory: 4 Hard... View the full answer

Capture.JPG

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online