Suppose the following constructor:
class Needed
{
public:
Needed () {}
Needed (const char *name) {}
};
class Dummy
{
public:
Dummy (): needed ( "Jimmy" ) {}
private:
Needed needed;
};
So, did I initialized needed twice here?
Suppose the following constructor:
class Needed
{
public:
Needed () {}
Needed (const char *name) {}
};
class Dummy
{
public:
Dummy (): needed ( "Jimmy" ) {}
private:
Needed needed;
};
So, did I initialized needed twice here?
No you initialized it only once in the Member Initializer List.
No, it only gets initialized once for each Dummy instance. You just supplied the arguments for its initialization (and selected which constructor to use).