I'm new to C++11 and I was wondering how this code works internally:
class MyClass
{
public:
MyClass(int a, double b) {
cout << "ctor()" << endl;
}
};
int main()
{
MyClass i1{4, 7};
return 0;
}
My understanding of the new initializer list is that it is a class std::initializer_list
constructed by special syntax { .... }
in the code. So how does this class instance created by {4, 7}
internally get transformed to a form that fits the constructor to MyClass
? Thanks.
Aucun commentaire:
Enregistrer un commentaire