#include <utility>
class C {
private:
const std::pair<int,int> corner1(1,1);
};
GCC reports error: expected identifier before numeric constant.
I need to construct the object on the moment of it’s declaration since it’s const, but I can’t seem it get the right syntax.
No, you can only initialize non-integral types – const or not (at least pre-C++11) in the constructor initializer list:
But it seems to me like you don’t need to replicate the member in every instance, so I’d just make it static instead: