Yes, it's legitimate. It's equivalent to putting the initialization in
the constructor. I believe that each initialization expression must be
stand-alone... that is, it can't use "this" to access other,
already-initialized members because the initialization order is not
guaranteed.
That said, I prefer to put everything in the constructor so that it's
all in one place. I find even class declarations like
int sales = 0;
to be annoying, because then I have to look two places (the constructor
and the member declaration) to see what the initial values are.
I know other people who avoid putting initialization code in
constructors and prefer member initializations. It's a style thing.
|