有如下类定义: class Father{ //基类 public: Father(string s):name(s) { } private: stri

admin2015-06-27  33

问题 有如下类定义:
       class Father{         //基类
       public:
           Father(string s):name(s) { }
       private:
           string name;
       };
       class Mother{         //基类
       public:
           Mother(string s):name(s) { }
       private:
           string name;
       };
       ___________________________{      //Father和Mother的派生类
       public:
           Child(string s1,string s2,string s3):Father(s1),Mother(s2),name(s3) { }
       private:
           string name;
       };
若派生类Child从基类Father和基类Mother处公有继承,则横线处缺失的部分是

选项 A、classChild
B、classChild:Father,Mother
C、classChild:publicFather,Mother
D、classChild:publicFather,publicMother

答案D

解析 一个派生类同时继承两个或者多个基类时称为多重继承,其一般形式为:class派生类名:[继承方式]基类名1,[继承方式]基类名2,所以D选项正确。
转载请注明原文地址:https://kaotiyun.com/show/49BD777K
0

最新回复(0)