Q:

Brace initialization for class with virtual function

There is this code:
struct A {
   int x;
   void f() {}
};

struct B {
   int y;
   virtual void f() {}
};

A a = {2};

//B b = {3}; error: no matching constructor for initialization of 'B'

int main() {
   return 0;
}

Why initialization for variable a works but not for variable b? 

A:

A is an aggregate, and so can have brace initialization, and B isn't, since it has a virtual method. 
8.5.1 Aggregates

An aggregate is an array or a class (Clause 9) with no user-provided constructors (12.1), no brace-or-equal-
  initializers for non-static data members (9.2), no private or protected non-static data members (Clause 11),
  no base classes (Clause 10), and no virtual functions (10.3).