Question: We have a class called electronic_device that shows the information of an electronic device with two attributes: serial_number and year_built. The classes phone and laptop

We have a class called electronic_device that shows the information of an electronic device with two attributes: serial_number and year_built. The classes phone and laptop are inherited from electronic_device. We have another class called smartphone that inherits from phone class. The code is provided bellow:
 We have a class called electronic_device that shows the information of
a) Write the implementation of the regular constructors (not default ones) of electronic_device and laptop classes:
b) Implement the print() function in phone class such a way that it prints out serial_number, year_built and number of cameras for a phone. (Make sure you use the print() function implemented in the base class (electronic_device) as well).
c) What will be the output of the following program (driver) based on the above classes?
an electronic device with two attributes: serial_number and year_built. The classes phone
d) Write the code for creating a dynamic object of smart phone class with these initial values: serial_number: "samsung123", year_built: 2020, number of camera:3, number_of_apps: 15. Then explain when you create these object which constructors and in which order they are called.

#include using namespace std; class electronic device protected: string serial number; int year_built; public: electronic_device(); electronic device(strings, int a); /"getters and setters/ virtual void print() { cout ); class phone: public electronic device protected: int number_of_camera; public: phone(); phone(string, int, int); "getters and setters virtual void print(); virtual-phone() cout }; class smartphone: public phone! protected: int number_of_apps; public: smartphone(); smartphone(string, int, int, int); Vetters and setters class laptop: public electronie_devicet protected: int n_of_cores; public: laptop(); laptop(string s, int a, int b); "getters and setters virtual void print() cout int main() electronic_device *e; e= new laptop ("del135", 2017, 7); e->print(); delete e; return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!