Task 1 Create a class Device which stores description as a string and use constructor to assign "device" to it. Also in constructor print oyt a message "I'm a Device constructor". In deconstructor print out "T'm a Device deconstructor". Do the same thing for new each class. 2 Create 2 different classes: Headphones and Microphone that inherit from class Device. Set one inheritance to private. Remember to avoid ambiguity with virtual public class. 3. Class Headphones should have method play() which prints out eg "play music", device_type that stores "headphones" as a string and color string that is assigned by default "black" with method get color() that returns it. Class Microphone should have method record() which prints out eg "record voice" and device_type string that stores "microphone" 5. Create class Headphones_with_microphone that inherit content from those two classes. Add method Get device_type() which returns string in a format: I'm a .. with.. Use scope operator = to gain access to device_type and avoid ambiguity. 6. Create a class Output which inherit data from class Headphones_with_microphone and add a method inside it Print_out() which will print out description, play(), record() and Get_device_type(). In main() create an object of type Output and use the Print_out() method. Change color of headphones only by using Output type object and scope operator and again use Print_out() method. You can change other things if you want. 4. 7. 8.
Task 1 Create a class Device which stores description as a string and use constructor to assign "device" to it. Also in constructor print oyt a message "I'm a Device constructor". In deconstructor print out "T'm a Device deconstructor". Do the same thing for new each class. 2 Create 2 different classes: Headphones and Microphone that inherit from class Device. Set one inheritance to private. Remember to avoid ambiguity with virtual public class. 3. Class Headphones should have method play() which prints out eg "play music", device_type that stores "headphones" as a string and color string that is assigned by default "black" with method get color() that returns it. Class Microphone should have method record() which prints out eg "record voice" and device_type string that stores "microphone" 5. Create class Headphones_with_microphone that inherit content from those two classes. Add method Get device_type() which returns string in a format: I'm a .. with.. Use scope operator = to gain access to device_type and avoid ambiguity. 6. Create a class Output which inherit data from class Headphones_with_microphone and add a method inside it Print_out() which will print out description, play(), record() and Get_device_type(). In main() create an object of type Output and use the Print_out() method. Change color of headphones only by using Output type object and scope operator and again use Print_out() method. You can change other things if you want. 4. 7. 8.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
This is my code till now.please modify this code to print the output.
#include<iostream>
using namespace std;
class Device
{
public:
string description;
Device()
{
description="Floppy Disk";
cout<<"I'm a Device constructor"<< endl;
};
~Device(){
cout<<"I'm a Device destructor"<<endl;
};
};
class Headphones:public Device{
void play(){
cout<<"Play Music"<<endl;
}
void device_type(){
string headphones;
string color="black";
}
std::string get_color(color)
{
return(color);
}
};
class Microphone: private Device{
void record(){
cout<<"Record voice"<<endl;
string device_type="microphone";
}
};
class headphones_with_microphone: public Headphones, public Microphone {
std::Get_device_type(){
return device_type;
}
};
class Output: headphones_with_microphone
{
void print_out(){
return(description);
play();
record();
Get_device_type();
}
};
int main() {
Output obj;
obj.print_out();
return0;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
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.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education