不在构造和析构过程中调用 virtual 函数

Never call virtual function during construction or destruction

Calling virtual functions from a constructor or destructor is considered dangerous most of the times and must be avoided whenever possible. All the C++ implementations need to call the version of the function defined at the level of the hierarchy in the current constructor and not further. 
You can call a virtual function in a constructor. The Objects are constructed from the base up, “base before derived”.

你可能感兴趣的:(C&C++,c++,开发语言)