有如下程序:includeusing namespace std;class TestClass1{public:virtual void fun( 有如下程序: #include<iostream> using namespace std; class TestClass1 { public: virtual void fun(){cout<<"1";} }; class TestClass2: public TestClass1 { public: TestClass2(){cout<<"2";} }; class TestClass3:public TestClass2 { public: virtual void fun(){TestClass2::fun();cout<<"3";} }; int main() { TestClass 1 aa,*p; TestClass2 bb; TestClass3 cc; p=cc; P->fun(); return 0; } 执行上面程序的输出是( )。A.1122B.2112C.2213D.2223
有如下程序:includeusing namespace std;class TestClass1{public:virtual void fun(
有如下程序: #include<iostream> using namespace std; class TestClass1 { public: virtual void fun(){cout<<"1";} }; class TestClass2: public TestClass1 { public: TestClass2(){cout<<"2";} }; class TestClass3:public TestClass2 { public: virtual void fun(){TestClass2::fun();cout<<"3";} }; int main() { TestClass 1 aa,*p; TestClass2 bb; TestClass3 cc; p=&cc; P->fun(); return 0; } 执行上面程序的输出是( )。
A.1122
B.2112
C.2213
D.2223
相关考题:
有如下程序:includeusing namespace std;Class Base{public:Base(){cout 有如下程序: #include<iostream.h> using namespace std; Class Base { public: Base(){cout<<“BB”;f();} void{(){cout<<“BF”;} }; class Derived:public Base { public: Derived(){cout<<“DD”;} void f(){cout<<“Df”;) }; int mainA.BBBfDDB.BBDfDDDfC.DDD.DDBBBf
有下列程序:include using namespace std; class TestClass1 { public: TestClass1(){ 有下列程序:include<iostream>using namespace std;class TestClass1{public:TestClass1(){cout<<"A";}};class TestClass2<public:TestClass2(){cout<<"B";}};class TestClass3:public TestClass1{TestClass2 b;
有如下程序:includeusing namespace std;class TestClass{private;char c;public;Tes 有如下程序: #include<iostream> using namespace std; class TestClass { private; char c; public; TestClass (char n):c(n){} ~TestClass () { cout<<c; } }; class TestClass1:public TestClass { Private: char c; public: TestClass1(char n):TestClass (n+1),c(n){} ~TestClass1() { cout<<c; } }; int main() { TestClass1 obj('x'); return 0; } 执行上面的程序输出( )。A.xyB.yxC.xD.y
有如下程序:includeusing namespace std;{TestClass(){cout 有如下程序: #include<iostream> using namespace std; { TestClass(){cout<<"BB";fun()} void fun(){cout<<"Bf";} }; class TestClass1:public TestClass { public: TestClass1(){cout<<"DD";} void fun(){cout<<"Df";} }; int main() {TestClass1 d; return 0;} 执行上面的程序将输出( )。A.BBBfDDB.BBDfDDDfC.DDD.DDBBBf
在下面程序中,括号里应填()。 include using namespace std; class A { public: void 在下面程序中,括号里应填( )。 #include <iostream> using namespace std; class A { public: void fun( ) { cout << "Hello" << endl; } }; class B:: public A { void fun( ) { ( ) //调用基类的函数fun( ) tout << "HI" << endl; } };A.fun()B.A. fun()C.A::fun()D.A-fun(
将下面程序补充完整。 include using namespace std; class Base{ public: 【 】fun(){r 将下面程序补充完整。include <iostream>using namespace std;class Base{public:【 】 fun(){return 0;} //声明虚函数};class Derived:public Base{public:x,y;void SetVal(int a,int b){}int fun(){return x+y;}};void 【 】 SetVal(int a,int b){x=a;y=b;} //类Derived成员函数void main(){Derived d;cout<<d.fun()<<endl;}
有如下程序:includeincludeusing namespace std;class BASE{char c;public 有如下程序: #include<iostream>#include<iosream> using namespace std; class BASE{ char c; public; BASE(char n):c(n){} virtual ~ BASE(){cout<<c;} }; class DERIVED; public BASE{ char c; public: DERIVED (char n): BASE (n+1)A.XYB.YXC.XD.Y
有如下程序: include using namespace std; class Base { public: 有如下程序: #include<iostream> using namespace std; class Base { public: void fun() { cout<<"Base::fun"<<endl; } }; class Derived: public Base { public: void tim() } ____________ cout<<"Derived:: fun"<<endl; } }; int main() { Derived d; d.fun(); return O; } 已知其执行后的输出结果为: Base::fun Derived::fun 则程序中下划线处应填入的语句是A.Base.fun();B.Base::fun();C.Base->fun();D.fun();
有如下程序:includeusing namespace std;Class TestClass{int a;public:TestClass(in 有如下程序: #include<iostream> using namespace std; Class TestClass {int a; public: TestClass(int x){a=x;} void show(){cout<<a;}}; class TestClass1:public TestClass {int b; public: TestClass1(int i):TestClass(i+1),b(i){} voiA.5B.1C.0D.2
阅读下列说明和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;}