Advantages of using initializer list? [duplicate]

If you don’t use the initializer list, the member or base class gets default constructed before the opening curly brace.

So, your calls to set it later will add an operator=() call.

If you use the initializer list, the member or base class has the proper constructor called.

Depending on your classes, this might be required or faster.

Leave a Comment