Description of this paper

overload the following operators

Description

solution


Question

we are going to overload the following operators in the fract class.;math operator add (+) operator;logical comparison greater than (>) operator;both pre and post increament (++) and decrement (--) operators;output stream (< 3/8;3/4 is greater than 3/8;Enter fraction, operator, fraction;form 3/4 + 3/8 (or 0/1 + 0/1 to exit): 3/8 > 3/4;3/8 is NOT greater than 3/4;Enter fraction, operator, fraction;form 3/4 + 3/8 (or 0/1 + 0/1 to exit): 3/5 1 1/2 where operator (1) is a pre-increament of operand 1;4/5;frac_oo.cpp, is;int main();frac f1, f2, fans;char op;do;cout << "nEnter fraction, operator, fraction;cout < > op;f2.inputfrac();switch(op);case '+;fans = f1 + f2;fans.outputfrac();break;case '-;fans = f1 - f2;fans.outputfrac();break;case '*;fans = f1 * f2;fans.outputfrac();break;case '/;fans = f1 / f2;fans.outputfrac();break;default;cout << "No such operator;//end switch;while(f1 != frac(0/1) || f2 != frac(0,1));cout << endl;return 0

 

Paper#67437 | Written in 18-Jul-2015

Price : $22
SiteLock