Suppose I define the following class:
class A
{
public:
int x;
};
Now I can initialize it like a struct:
A a { .x = 1; }
However, when I define any virtual function, the constructor goes away:
class A
{
public:
int x;
virtual int f() {}
};
A a { .x = 1; }
The message is:
# error: no matching function for call to ‘A::A(<brace-enclosed initializer list>)’
Why does a virtual function delete that constructor?