dimanche 3 mai 2015

Are empty braces and default initialization always equivalent?

As a follow-up question to 'Do parentheses after the type name make a difference':

If 'Test' is an ordinary class, is there any difference between:

Test* test = new Test();
// and
Test* test = new Test{};

Furthermore, suppose Test2 has a constructor for an argument of type Value, is it always equivalent to write:

Value v;
Test2 *test2 = new Test(v);
// and
Test2 *test2 = new Test{v};

Aucun commentaire:

Enregistrer un commentaire