I am trying to compile an application which is showing error in following line:
enum class HoleMaskPixelTypeEnum {HOLE, VALID, UNDETERMINED};
I haven't uses enum is such way along with class keyword. If I comment the keyword class then following error occur
error C2864: 'HolePixelValueWrapper<T>::Value' : only static const integral data members can be initialized within a class
which is in following code:
template <typename T>
struct HolePixelValueWrapper
{
HolePixelValueWrapper(const T value) : Value(value){}
operator T()
{
return this->Value;
}
T Value = 0;//error here.
};
No idea to solve it.
Scoped enumerations (enum class
) and in-class initialisation of member variables are a fairly new language features (introduced in C++11); according to this table, the former needs Visual Studio 11.0 or later, and the latter is not yet supported.
If your compiler doesn't support scoped enumerations, then the only option is to remove class
. You might consider scoping it inside a class or namespace, if you don't want to cause wider pollution.
If it doesn't support in-class initialisation, then you'll just have to do it the old-fashioned way in the constructor(s). However, there's no point using it here anyway, since the member is initialised by the only constructor. Just remove the = 0
.
enum class Blah
is a C++11 feature. Are you compiling with a C++11 compiler?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With