- Q3 15 Marks Write A C Program To Test The Class My Exception Defined Below By Promoting A User To Enter Their Age 1 (35.18 KiB) Viewed 12 times
Q3: (15 MARKS) Write a C++ program to test the class my Exception defined below by promoting a user to enter their age.
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Q3: (15 MARKS) Write a C++ program to test the class my Exception defined below by promoting a user to enter their age.
Q3: (15 MARKS) Write a C++ program to test the class my Exception defined below by promoting a user to enter their age. If age is less than 19 throw an exception with the default constructor, age between 19 to 35 (inclusive) no exception is thrown, display a message "Access granted.", otherwise throw an exception using a non-default constructor with a message of your choice. Write a complete program (i.e. repeat the class myException on your file). Save the file as myException.cpp class myException { private: string message; public: myException(); myException (string); string what (); myException::myException () ( message "Youngster!"; cout << "Parental attention required!"<< endl; > myException::myException (string msg) ( message msg; cout << "Immediate Attention required!" << endl; ) string myException::what () ( return message; >