class Core
{
public:
Core(void);
Core(std::istream& );
};
class Grad :public Core
{
public:
Grad(void);
Grad(std::istream& );
};
Grad类派生自Core
int main (int __argc, int __argv)
{
Grad grad(cin);
}
执行结果:
__thiscall Core::Core(void)
__thiscall Grad::Grad(class std::basic_istream<char,struct std::char_traits<char> > &)
Grad类的两个构造函数,只要不在初始化的时候显示的调用基类(Core)的构造函数,编译器将调用基类默认构造函数(Core::Core())来构造对象的基类部分。
知道真相的我,眼泪掉下来,为什么Grad grad(cin)时,不能智能的调用基类的Core::Core(std::istream&)构造函数呢?