类的Ctor-initializer不会调用适当的构造函数

ste*_*lla 0 c++ constructor

我正在玩构造/破坏对象.这是我尝试过的http://coliru.stacked-crooked.com/a/ff17cc5649897430:

#include <iostream>

struct B{
    B(){ std::cout << "B()" << std::endl; }
    B(int){ std::cout << "B(int)" << std::endl; }
};

struct A : virtual B
{
    int B;
    A(int a) : B(a) { std::cout << "A(int)" << std::endl; }
} a(10);

int main()
{
}
Run Code Online (Sandbox Code Playgroud)

程序输出是

B()
A(int)
Run Code Online (Sandbox Code Playgroud)

为什么?我明确指定了B要在ctor-initializer中调用的类的构造函数.

Mic*_*ers 5

B(a)正在建设中的B成员变量.更好地命名您的变量,您将看到您想要看到的内容.