( 13 )有如下类定义和变量定义:class Parents{public:int publicuata;private:int privateData;};class ChildA:public Parents{/* 类体略 */};class ChildB:private Parents{/* 类体略 */ ) ;ChildA a;ChildBb;下列语句中正确的是A ) couta.publicData endl ;B ) couta.privateData endl ;C ) coutb.publicData endl ;D ) coutb.privateData endl ;
( 13 )有如下类定义和变量定义:
class Parents{
public:
int publicuata;
private:
int privateData;
};
class ChildA:public Parents{/* 类体略 */};
class ChildB:private Parents{/* 类体略 */ ) ;
ChildA a;
ChildBb;
下列语句中正确的是
A ) cout<<a.publicData <<endl ;
B ) cout<<a.privateData <<endl ;
C ) cout<<b.publicData <<endl ;
D ) cout<<b.privateData <<endl ;
相关考题:
有如下类定义,请将Sample类的复制构造函数补充完整。class Sample{public:Sample( ){ }~Sample( ){if(P)delete P;)Sample(const Samples){______}void SetData(int datA) {P=new int(datA) ;}private:int*P:};
用于定义类成员的访问控制权限的一组关键字是A.extends 和 implementsB.public,private 和 protectedC.class和publicD.char,int,float和double
有如下类定义,请将Sample类的拷贝构造函数补充完整。class Sample{public:Sample(){)~Sample(){if(p)delete p;)Sample(const Sample s){______}void SetData(int data) {p=new int(data);}private:int*p;};
下列选项中,列出用于定义类成员的访问控制权的一组保留字是 ( )A.class,float,double,publicB.float,boolean,int,longC.char,extends,float,doubleD.public,private,protected
下列选项中,列出用于定义类成员的访问控制权的一组保留字是______。A.float,boolean,int,longB.class,float,double,publicC.char,extends,float,doubleD.public,private,protected
有如下类定义和变量定义: class Parents{ public: int publicData: private: int privateData; }; class ChildA:public Parents{/类体略*/}; class ChildB:private Parents{/类体略*/}; ChildA a; ChildB b; 下列语句中正确的是A.cout<<a.publicData<<endl;B.cout<<a.privateData<<endl;C.cout<<b.publieData<<endl;D.eout<<b.privateData<<endl;
下列选项中,列出用于定义类成员的访问控制权的一组保留字是()。A.class.float.double.publicB.fioat.Boolean.int,longC.char.extends.float.doubleD.public.private.protected
阅读下列说明和C++代码,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。【说明】以下C++代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分类及其关系如图6-1所示。【C++代码】#include?#include?using?namespace?std;class?DrawCircle?{??????//绘制圆形,抽象类? ? ? public: (1);//定义参数为?int?radius,?int?x,?inty? ?virtual~DrawCircle()?{?}};class?RedCircle:public?DrawCircle?{????//绘制红色圆形? ? ? ? public: void?drawCircle(intradius,?int?x,?int?y)?{cout??drawCircle?=?drawCircle;? }? ?virtual~shape()?{?}? public:? ?virtual?void?draw()?=?0;};class?Circle:public?Shape?{????//圆形? ? private:? ? ?int?x,y,radius;? ? public:? Circle(int?x,inty,int?radius,DrawCircle?*drawCircle)? (3)? {? this->x?=?x;? ?this->y?=?y;? ? this->radius?=?radius; }? ? ? public:? void?draw(){? drawCircle?-> (4); }};int?main(){Shape?*redCirclenew?Circle(100,100,10,????(5)????);//绘制红色圆形? Shape?*greenCircle=new?Circle(100,100,10, (6)??);//绘制绿色圆形redCircle >draw();? ?greenCircle?->draw();? ?return?0;}
有如下类定义,请将Sample类的拷贝构造函数补充完整。 class Sample { public: Sample(){} ~Sample(){if(p)delete p;} Sample(const Samples){ p=new int; *p=___________; } void SetData(int data) {p=new int(data);} void print(){cout<<*p<<endl;} private: int*p; };
用于定义类成员的访问控制权的一组关键字是()A.class, float, double, publicB.float, boolean, int, longC.char, extends, float, doubleD.public, private, protected