Default member initializer not being set C++

98 Views Asked by At

I have the following code:

class Foo
{
public:
  enum class MyEnum
  {
     option1,
     option2
  }
  "Some constructors"

private:
  "Some members and the following member"
  MyEnum enum_ = MyEnum::option1;
}

So basically, none of the constructors are setting the enum_ option, which is good. Because for all of them I want this value to be default set to option1. The problem is that after creating Foo object, option1 is not initialized for the enum_ value. None of option1/option2 is. The value is simply not initialized. I am wondering what I am doing wrong.

0

There are 0 best solutions below