Question: Write the C + + code to implement the Calculator class, as specified below: [ 2 points for using the correct syntax to declare a

Write the C++ code to implement the Calculator class, as specified below:
[2 points for using the correct syntax to declare a Calculator class]
The Calculator class should have one private data member, called ans, which stores the result of the previous calculation in a double variable. [3 points]
The Calculator class should have a constructor which does not take any arguments, and initializes ans to 0.0.[3 points]
The Calculator class should have three functions other than the constructor: add, divide, and getAns. The add function should take two int arguments, add them together, store the result in ans, and then return the resulting int. The divide function should take two double arguments, divide the first argument by the second argument, store the result in ans, and then not return anything. The getAns function should take no arguments and simply return ans. [12 points: 4 per function]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!