I was trying to use brace-initialization (which thankfully Visual Studio 2013 actually supports), but for some reason when I do it on a class, it requires two sets of braces. For example:
class NumberGrabber {
int number;
public:
NumberGrabber() : number{ 5 }{}
int getNumber() { return number; }
};
Why does it require me to say number { 5 }{}? That doesn't really make visual sense to me.
The former set of braces is the initializer for
number, the latter is the compound statement that defines the body of the constructor. With proper formatting, this may become clearer.Does that make more sense?