Question: Add a constructor initializer list to the overloaded constructor Recording(string newTopic, int newDuration, char newOnSale) to initialize topic with newTopic, duration with newDuration, and onSale
Add a constructor initializer list to the overloaded constructor Recording(string newTopic, int newDuration, char newOnSale) to initialize topic with newTopic, duration with newDuration, and onSale with newOnSale.
Ex: If the input is Cars 58 N, then the output is:
Recording: Unrecorded, Duration: -10, On Sale: ? Recording: Cars, Duration: 58, On Sale: N
#include
class Recording { public: Recording(); Recording(string newTopic, int newDuration, char newOnSale); void Print() const; private: string topic; int duration; char onSale; };
Recording::Recording() : topic("Unrecorded"), duration(-10), onSale('?') { }
Recording::Recording(string newTopic, int newDuration, char newOnSale) /* Your code goes here */ { }
void Recording::Print() const { cout << "Recording: " << topic << ", Duration: " << duration << ", On Sale: " << onSale << endl; }
int main() { Recording myRecording; string newTopic; int newDuration; char newOnSale; cin >> newTopic; cin >> newDuration; cin >> newOnSale; Recording yourRecording(newTopic, newDuration, newOnSale);
myRecording.Print(); yourRecording.Print(); return 0; }
c++ and please please make it corrrect
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
