What I'm trying to figure out is why "cout << (result.IntCheck() ? result.Float() : result ) << endl;" calls a constructor for a new Fraction object after result.IntCheck() returns true and result.Float() returns a double value.
The reason I know that a constructor is called after result.Float() returns is because I used gnu debugger.
shall return the common type for operands result.Float() and result.
Expression result.Float() has type double while expression result has type Fraction. An object of type Fraction can not be converted to type double because your class has no such conversion function. However an object of type double can be converted to an object of type Fraction because the class contains constructor that takes one argument
Fraction(int n = 0, int d = 1);
So the common type for the expression will be Fraction. The compiler creates a temporary object of type Fraction using the following call