1

I was reading about user-defined literals, and I came across this snippet, but I got compiler error when I tried to use it.

int operator ""_fix(long double d)
{
     // returns d as a 1.15.16 fixed point number
     return (int)(d*65536.0f);
}

It says Error : Expected an operator. I am on Visual STudio 2013, which I believe has good support for C++ 11. Any ideas what is going wrong?

The Vivandiere
  • 3,059
  • 3
  • 28
  • 50

1 Answers1

-2

Remember that there must be a space after "" and before the suffix. So you should write:

int operator "" _fix(long double d)
{ // ...
nwp
  • 9,623
  • 5
  • 38
  • 68
Jurek
  • 1