bool a{ false };
Now I created a boolean variable, but if I want to do this:
a { false };
a = false;
The first method doesn't work, what's the reason?
bool a{ false };
Now I created a boolean variable, but if I want to do this:
a { false };
a = false;
The first method doesn't work, what's the reason?
You can only do uniform initialization (or any form of initialization) when an object is created. After an object is initialized, you can only modify it:
bool a{false}; // brace initialization
bool b = false; // copy initialization
// a and b are created now, and can't be initialized again
a {false}; // not valid syntax
b = false; // assignment, NOT initialization