โ Back to Classes
Question 149
Throw in Constructor
Throw in Constructor
Create a classRectanglewith privatedouble widthanddouble height. Requirements: 1. ConstructorRectangle(double w, double h): if eitherworhis less than or equal to 0, throw astd::invalid_argumentwith the message"Dimensions must be positive". Otherwise assign them to the fields. 2.double area() const: returnswidth * heightDo NOT write a main function.
Expected Output:
50
Topics:
ClassesExceptions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.