Hello everybody,
I created a class managing fractions named ZFraction.
Here is the code of the operator- function (out of the class) which is the minus operator:
1 2 3 4 5 6
ZFraction operator-(ZFraction const& a)
{
ZFraction copie(a);
copie*=-1; // here I don't understand
return copie;
}
I guess -1 is converted into a ZFraction object, but I tried to write
copie*=(-1,2)
and the compiler says that left operand of comma operator has no effect so it multiplies the current fraction object by 2.
Because (-1, 2) is equal to 2. If you want to creeate a Fraction object, you should write Fraction(-1, 2), or you can try uniform initialisation and do copie *= {-1,2};
I've tried to put copie*={-1,2}; and the compiler complains with 2 warnings, saying :
1 2
warning: extended initializer lists only available with -std=c++11 or -std=gnu++11[enabled by default]
warning: extended initializer lists only available with -std=c++11 or -std=gnu++11[enabled by default]