dimanche 25 février 2018

Delegation vs Instantiation

Say if I have a class A with an instance variable B b;. What's the difference between initializing the variable in A's constructor or using constructor delegation?

class A
{
public:
    A();

private:
    B b;

};

What's the difference between:

A::A() {
    this.b = B();
}

and

A::A() : b() {}

Aucun commentaire:

Enregistrer un commentaire