Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Initializing Variables in C++

  1. {} is more powerful than () and thus is preferred over (). You should use always use {} except for a few cases where () is necessary. For example, if you want to create a vector of length 1000, you have to use
    vector<int>(1000);
    

instead of

    vector<int> {1000};

which create a vector …