what is the difference between using an initializer list or to duplicate one?

In your example there is no difference, you can use either of them, but, there exist some differences in some other context, for example, you can use curly braces to initialize a vector see below program.


int main(){

    std::vector<int> first(12,3,5,6);   // Compile time error
    std::vector<int> second{12,3,5,6};  // Ok 

    return 0;

Hope, this helps you understand the difference, for more information, you should check the link mentioned by @Thomas Salik. Link.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top