Question: Model III. (20 min) Designing a C++ Class start time: A simple class might have only one data field and a few methods that manipulate



Model III. (20 min) Designing a C++ Class start time: A simple class might have only one data field and a few methods that manipulate that data field. Data fields will be represented in the C++ class by a member/instance variable. By marking this instance variable private, we will have the opportunity to handle invalid values. By labeling this instance variable private, we will have the opportunity to handle invalid values. Create and save a new C++ class (Salary.cpp) with the following code: /** Represents the salary for a person */ class Salary private: double annual; public: void setAnnualSalary(double salary) { annual = salary: } double getAnnualSalary() return annual; } }; Instructions: Now add the following main method to the end of the Salary class file (outside of the class): int main() { Salary pay; pay.setAnnual Salary (64100); return 0; } Critical Thinking Questions 19. Identify the two syntax changes that must be made to a method when a method has a return value. 23. Modify the Salary class to reject invalid salary values. Give your new code here (the entire modified method)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
