( 12 )有如下程序:#includeusing namespace std;clsaa CA{public:CAD{coutA ’ ;}};class CB ;private CA{public;CB () {coutB ’ ;}};int main () {coutB ’ ;}};int main () {CA a;CB b;retum0;}这个程序的输出结果是 【 12 】 。
( 12 )有如下程序:
#include
using namespace std;
clsaa CA{
public:
CAD{cout<<A ’ ;}
};
class CB ;private CA{
public;
CB () {cout<<B ’ ;}
};
int main () {cout<<B ’ ;}
};
int main () {
CA a;
CB b;
retum0;
}
这个程序的输出结果是 【 12 】 。
相关考题:
有如下程序:#includeusing namespace std;class Base{public:void funl(){cout"Base\n";}virtual void fun2(){cout"Base\n";}};class Derived:public Base{public:void funl(){cout"Derived\n";}void fun2(){cout"Derived\n";}};void f(Base B . {b.funl();b.fun2();}, lt;, /Pint main(){Derived obj;f(obj);return 0;}执行这个程序的输出结果是A . Base BaseB . Base DerivedC . Derived BaseD . Derived Derived
有如下程序:#includeusing namespace std;class PARENT{public:PARENT(){cout"PARENT";}};class SON:public PARENT{public:SON(){cout"SON";}};int main(){SON son;PARENT *p;p = son;return 0;}执行上面程序的输出是 【 12 】 。
若有如下程序:includeusing namespace std;Class TestClass1{private:int a;public:T 若有如下程序: #include<iostream> using namespace std; Class TestClass1 { private: int a; public: TestClassl(int i) { a=i; } void disp() { cout<<a<<“,”; } }; Class TestClass2 { private: int b; publicA.10,10,10B.10,12,14C.8,10,12D.8,12,10
在下面程序的画线处填上适当的内容,使程序执行后的输出结果为ABCD。 include using 在下面程序的画线处填上适当的内容,使程序执行后的输出结果为ABCD。include <iostream>using namespace std;class A{public:A( ){cout<<'A';}};class B: (11) {public:B( ){cout<<'B';}{;class C: (12) {public:C( ){cout<<'C';}};class D:public B,public C{public:D( ){cout<<'D';}};void main( ){D( );cout<<endl;}
有如下程序: #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;}
有以下程序:当执行程序时,按下列方式输入数据(从第l列开始,<;CR>;代表回车,注意:回车也是一个字符]12<;CR>;34<;CR>;则输出结果是( )。A.12B.123C.1234D.12343
若有以下程序:includeusing namespace.std;class data{public: int x; data (int x) 若有以下程序: #include<iostream> using namespace.std; class data { public: int x; data (int x) { data::x=x; } ); class A { private: data d1; public: A(int x) :dl(X){} void dispa() { cout<<dl.X<<","; } }; class B:public A { private: data d2; public: B(int x) : A(x-1),d2(x){} void dispb() { cout<<d2.x<<endl; } }; class C:public B { public: C(int x) :B(x-1){} void disp() { dispa(); dispb(); } }; int main() { C obj(5); obj.disp(); return 0; } 程序执行后的输出结果是A.5,5B.4,5C.3,4D.4,3
阅读下列说明和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;}