Question
Add a constructor initializer list to the default Appointment constructor to initialize month with Unrecorded, date with -100, and weekday with 'X'. Ex: If the
Add a constructor initializer list to the default Appointment constructor to initialize month with "Unrecorded", date with -100, and weekday with 'X'.
Ex: If the input is Jul 10 T, then the output is:
Appointment: Unrecorded, Date: -100, Weekday: X Appointment: Jul, Date: 10, Weekday: T
#include
class Appointment { public: Appointment(); void SetFields(string newMonth, int newDate, char newWeekday); void Print() const; private: string month; int date; char weekday; };
Appointment::Appointment() /* Your code goes here */ { }
void Appointment::SetFields(string newMonth, int newDate, char newWeekday) { month = newMonth; date = newDate; weekday = newWeekday; }
void Appointment::Print() const { cout << "Appointment: " << month << ", Date: " << date << ", Weekday: " << weekday << endl; }
int main() { string newMonth; int newDate; char newWeekday; Appointment myAppointment; myAppointment.Print(); cin >> newMonth; cin >> newDate; cin >> newWeekday; myAppointment.SetFields(newMonth, newDate, newWeekday); myAppointment.Print(); return 0; }
c++ and please make it correct
Step 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