I am trying to play with literal operators and I am a beginner. I have the following code snippet for which I am getting a few errors. Could someone help me with reasons why I get these 3 errors?
#include <iostream>
using namespace std;
constexpr float operator "" _km(float);
int main()
{
auto distance{2.3_km};
cout<<distance;
return 0;
}
Error:
3:42: error: 'constexpr float operator""_km(float)' has invalid argument list
In function 'int main()':
6:22: error: unable to find numeric literal operator 'operator""_km'
6:22: note: use -std=gnu++11 or -fext-numeric-literals to enable more built-in suffixes
6:28: error: unable to deduce 'std::initializer_list<auto>' from '{<expression error>}'
Aucun commentaire:
Enregistrer un commentaire