Invalid suffix on floating constant

66 Views Asked by At

I created a user-defined literal like this:

friend fraction operator "" _frac(long double val)
{
    return fraction((float)val);
}

(Yes I know converting from long double to float is not good but I just do this for testing first and then fix that) But then when I call like this:

fraction d= 1.0_frac; //error here
cout<<d;

The compiler (c++ 98) says:

[Error] invalid suffix "_frac" on floating constant

Is it because 1.0 is considered a float, not a long double?

0

There are 0 best solutions below