Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Could you answer and explain the following question. Given main() and the Instrument class, define a derived class, String Instrument, for string instruments. Ex. If
Could you answer and explain the following question.
Given main() and the Instrument class, define a derived class, String Instrument, for string instruments. Ex. If the input is: Drums Zildjian 2015 2500 Guitar Gibson 2002 1200 6 19 the output is: Instrument Information: Name : Drums Manufacturer: Zildjian Year built: 2015 Cost : 2500 Instrument Information: Name: Guitar Manufacturer: Gibson Year built: 2002 Cost: 1200 Number of strings: 6 Number of frets: 19File is marked as read only Current file: main.cpp 1 #include "StringInstrument.h" int main( ) { Instrument my Instrument; StringInstrument myStringInstrument; string instrumentName, manufacturerName, stringInstrumentName, stringManufacturer, yearBuilt, 8 cost, stringYearBuilt, stringCost, numStrings, numFrets; 9 10 getline(cin, instrumentName); 11 getline (cin, manufacturerName) ; 12 getline(cin, yearBuilt); 13 getline(cin, cost); 14 15 getline(cin, stringInstrumentName) ; 16 getline(cin, stringManufacturer); 17 getline(cin, stringYearBuilt); 18 getline(cin, stringCost); 19 getline(cin, numStrings); 20 getline(cin, numFrets); 21 22 my Instrument . SetName (instrumentName ); 23 my Instrument . SetManufacturer (manufacturerName) ; 24 my Instrument . SetYearBuilt (yearBuilt); 25 my Instrument . SetCost (cost); 26 my Instrument . PrintInfo ( ) ; 27 28 myStringInstrument . SetName (stringInstrumentName) ; 29 myStringInstrument . SetManufacturer(stringManufacturer) ; 30 myString Instrument . SetYearBuilt(stringYearBuilt); 31 myStringInstrument . SetCost(stringCost) ; 32 myString Instrument . SetNumOfStrings(numStrings); 33 myStringInstrument . SetNumOfFrets (numFrets ) ; 34 myStringInstrument . PrintInfo(); 35 36 cout #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started