jeudi 29 janvier 2015

how does member declaration with assignment relate to ctors?

Sorry - I'm sure I'm just not finding any answers because I don't know the nomenclature!



class Foo
{
public:
Foo() { } // default ctor
explicit Foo(int a) _a(a) { } // semi-explicit - but what is _b's value??
protected:
int _a = 9; // HOW DOES THIS RELATE TO EACH OF THE CTORS?!
int _b = 3; // HOW DOES THIS RELATE TO EACH OF THE CTORS?!
};


By explicitly specifying a default ctor w/o specifying _a or _b, do the declared assignments happen (_a = 9, _b = 3) or do those only happen if I don't create a default ctor (or I declare as Foo() = default;)?


Aucun commentaire:

Enregistrer un commentaire