Overloaded methods for the operations of adding subtracting


The main function is provided that will create an object of the calculator class and calling methods from this object. The calculator class definition will have to be defined in the "calculator.h" file. The class should have the prototypes for all the methods called in the "main" function and a private double variable for holding the running answer ("ans"). The implementation for the methods should be in a separate "calculator.cpp" file.All the methods (add, sub, ....) modify the private answer "ans" variable in the class object. The print_ans() method should be exclusively used in the other methods for printing the answer to the screen. Each addition, subtraction, division, and multiplication method should also output to the screen which numbers are being operated on and which operation is performed.

Overloaded methods for the operations of adding, subtracting, multiplication, and division will need to be created requiring one or two arguments. The single argument is added to, subtracted from, divided over, or multiplied by the running answer. The "main" function should clarify which overloaded methods should be generated. The main function shouldn't need altering, hopefully.

Attachment:- main.zip

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Overloaded methods for the operations of adding subtracting
Reference No:- TGS01245935

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)