有如下程序:#includeiostreamusing namespace std;class C1{public:-Cl()}cout1;}};class C2:public C1{public:~c2(){cout2;}};int main(){C2 cb2;C1*cbl:return 0;{运行时的输出结果是A.121B.21C.211 D、12
有如下程序:
#include<iostream>
using namespace std;
class C1{
public:
-Cl()}cout<<1;}
};
class C2:public C1{
public:
~c2(){cout<<2;}
};
int main(){
C2 cb2;
C1*cbl:
return 0;
{
运行时的输出结果是
A.121
B.21
C.211 D、12
相关考题:
( 31 )有如下程序:#includeiostreamusing namespace std;class C1{public:~C1(){ cout1; }};Class C2: public c1{public:~c2(){ cout2; }};int main(){C2 cb2;C1 *cb1;return 0;}运行时的输出结果是A ) 121B ) 21C ) 211D ) 12
有如下程序: #includeiostream usingnamespacestd; classTest( public: Test( ){} Test(constTest8Lt){cout1;} }; Testfun(Test&u){Testt=U;returnt;} intmain( ){Testx,y;x=fun(y);return0;} 运行这个程序的输出结果是( )。A.无输出B.1C.1lD.111
请将如下程序补充完整,使得输出结果为:bbaa。 include using naluespace std; class 请将如下程序补充完整,使得输出结果为:bbaa。include<iostream>using naluespace std;class A{public:______{eout<<"aa";}};class B:public A{public:~B( ){eont<<"bb";}};int ulain( ){B*P=new B;delete P;return 0;}
有如下程序: #includeiostream usingnamespacestd; classC1{ public: ~C1( ){cout1;) }; classC2:publicC1{ public: ~C2( ){cout2;) }; intmain( ){ C2cb2; C1*cb1: return0; } 运行时的输出结果是( )。A.121B.21C.211D.12
有以下程序:include using namespace std;class Base{public:Base(){}virtual void w 有以下程序: #include <iostream> using namespace std; class Base { public: Base(){} virtual void who() { cout<<"Base Class"<<end1; } ~Base(){} }; class Derivel : public Base { public: void who() { cout<<"Derivel Class"<<end1; } }; class Derive2 : public Base { public: void who () { cout<<"Derive2 Class"<<end1; } }; int main () { Base *p; Derivel obj1; Derive2 obj2; p=obj1; p=obj2; p->who ( ); return 0; } 执行程序后的输出结果是( )。A.Base ClassB.Derivel ClassC.Derive2 ClassD.程序编译时出错
有如下程序:includeusing namespace std;class C1{public:~Cl( ){cout 有如下程序: #include<iostream> using namespace std; class C1{ public: ~Cl( ){cout<<1;} }; class C2:public C1{ public: ~C2( ){cout<<2;} }; int main( ){ C2 cb2; C1*cb1: return 0; } 程序的输出结果是A.121B.21C.211D.12
阅读下列说明和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;}
2、类class C1的说明如下,错误的语句是() class C1{ int a;//(a) void //(b) public: C1(int val);//(c) ~C1();//(d) };A.aB.bC.cD.d
类class C1的说明如下,错误的语句是() class C1{ int a;//(a) void //(b) public: C1(int val);//(c) ~C1();//(d) };A.aB.bC.cD.d