In short, i made class Fraction:
class Fraction
{
int N;
int D;
public:
ostream& operator <<(ostream &);
operator float();
};
and in function main() i have:
Fraction a(3, 4);
cout << a << " = " << endl;
cout << (float)a << endl;
as output i get:
0.750000 = 0.750000
Why operator << is unused ( it should print "( 3/4 )" ).
My operator << working correctly if i delete operator float, but i need conversion Fraction to float for some other methods and functions. How can i use my output operator.
Wanted output:
( 3/4 ) = 0.750000