The initialization of the Cpp object is controlled by the constructor, so why is there {} initialization when there is () to call the constructor?

for initiailzer_list , why does Cpp provide only the default constructor: cppreference ;
then let me initialize vector:

.
struct A{
    A(int a, int b){this->a = 2*a; this->b = 2*b;}

    int a;
    int b;
};

A a{1, 2}; // (2, 4)

what is brace (list) initialization designed for?

CPP
Aug.16,2021

which compiler does the main building use? Vector < int > vec (initializer_list < int > ()); gPP7.3 can be compiled in the past


parenthesis initialization is ambiguous, and calling the constructor is indistinguishable from the function declaration. That's why CPP11 added curly braces for initialization.
check this out:
Most Vexing Parse

Menu