I have a code like the snippet below:
const int defval = -2e9;
struct defint
{
int i = -defval;
bool operator==(const int& j) { return i == j; }
defint& operator=(int x) { i = x; return *this; }
};
This gives me C2065: 'defval': undeclared identifier
, but the defval
is obviously declared before. How do I use the declared const
in a struct
or class
so that the compiler sees it as it should?
5