struct A
{
int a;
int b;
void foo(){}
};
A a{1, 2};
It works fine. But if change foo to a virtual function, It will not compile with error,
Error C2440 'initializing': cannot convert from 'initializer list' to
I find this,
An aggregate is an array or a class (Clause 9) with no user-provided constructors (12.1), no private or protected non-static data members (Clause 11), no base classes (Clause 10), and no virtual functions (10.3).
But what's the reason behind it?
Aucun commentaire:
Enregistrer un commentaire