网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
有如下程序include using namespace std;class A{public:virtual void func1 (){ cou

有如下程序#include <iostream>using namespace std;class A{public:virtual void func1 (){ cout<<"A1"; }void func2(){ cout<<"A2"; }};class B: public A{public:void func l(){ cout<<"B1"; }void func2(){ cout<<"B2"; }};int main() {A *p=new B;p->func1();p->func2();return 0;}运行此程序,屏幕上将显示输出( )。

A.B1B2

B.A1A2

C.B1A2

D.A1B2


参考答案

更多 “ 有如下程序include using namespace std;class A{public:virtual void func1 (){ cou 有如下程序#include <iostream>using namespace std;class A{public:virtual void func1 (){ cout<<"A1"; }void func2(){ cout<<"A2"; }};class B: public A{public:void func l(){ cout<<"B1"; }void func2(){ cout<<"B2"; }};int main() {A *p=new B;p->func1();p->func2();return 0;}运行此程序,屏幕上将显示输出( )。A.B1B2B.A1A2C.B1A2D.A1B2 ” 相关考题
考题 有如下程序: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 class SomeClass { public: SomeClass(int va 下列程序的运行结果是【 】。include <iostream. h>class SomeClass{public:SomeClass(int value) { some_value=value;};void show_data(void) { cout<<data<<"<<~some_value<<endl; };static void set_data(int value) {data=value; }private:static int data;int some_value};int SomeClass::datavoid main(void){SomeClass my_class(1001),your_class(2002);your_class. set_data(4004);my_elass. show_data()}

考题 下列程序的运行结果是______。 include class A { public: virtual void use( ) {cou 下列程序的运行结果是______。include<iostream.h>class A{public:virtual void use( ) {cout<<"in A\n";}};class B:public A{public:virtual void use( ) {cout<<"in B\n";}};class C:public B{public:virtual void use( ){cout"in C\n";}};void main( ){A*obj;bj=new C;obj->use( );delete obj;}

考题 有如下程序: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

考题 请将如下程序补充完整,使得输出结果为: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;}

考题 有以下程序:includeusing namespace std;class BASE{private: char c;public: BASE(c 有以下程序: #include <iostream> using namespace std; class BASE { private: char c; public: BASE(char n):c(n);{} virtual~BASE() { cout<<c; } }; class DERIVED:public BASE { char c; pA.XYB.YXC.XD.Y

考题 有如下程序:includeusing namespace std;class B{public:Virtual void show(){cout 有如下程序: #include<iostream> using namespace std; class B{ public: Virtual void show(){cout<<“B”;} }; class D:publicB{ public: void show(){cout<<“D”;} }; void funl(B*ptr){ptr->show();} void{un2(Bref){ref.show();} voidA.BBBB.BBDC.DBBD.DBD

考题 有下列程序:includeusing namespace std;class TestClass{protected:TestClass(){cou 有下列程序: #include<iostream> using namespace std; class TestClass{ protected: TestClass(){cout<<'x';} TestClass(char c){cout<<c;} }; class TestClassl:public TestClass{ public: TestClassl(char c){cout<<c;}A.yB.yxC.xyD.yy

考题 阅读下列说明和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;}