单选题 有如下程序: #include #include using namespace std; class Father{ public: Father(string s):name(s) { cout<<'F'; } ~Father() { } private: string name; }; class Mother{ public: Mother(string s):name(s) { cout<<'M'; } ~Mother() { } private: string name; }; class Child:public Mother,public Father{ public: Child(string s1,string s2,string s3,int a):Father(s1),Mother(s2),name(s3),age(a) { cout<<'C'; } ~Child() { } private: string name; int age; }; int main(){ Child son("Zhang","Li","Ming",20); return 0; } 运行时的输出结果是
【正确答案】 C
【答案解析】解析:执行派生类构造函数的顺序是:1、调用基类构造函数,2、调用子对象构造函数,3、再执行派生类析构函数,4、执行基类的析构函数。所以本题中执行构造函数为先执行基类Mother的构造函数、然后执行基类Father的构造函数,再执行派生类的构造函数函数,所以输出MFC,答案C正确。