网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
下列程序的输出结果是【】。 include using namespace std; class A {int a; public:A()
下列程序的输出结果是【 】。
include <iostream>
using namespace std;
class A {
int a;
public:
A():a(9){}
virtual void print() const { cout<<a;};
};
class B: public A {
char b;
public:
B( ){b='S';}
void print() const {cout<<b;}
};
void show(A &x){ x.print0;}
int main()
{ Ad1,*p;
B d2;
p=&d2;
d1.print();
d2.print0;
p->print();
show(d1);
show(d2);
return 0;}
参考答案
更多 “ 下列程序的输出结果是【】。 include using namespace std; class A {int a; public:A() 下列程序的输出结果是【 】。include <iostream>using namespace std;class A {int a;public:A():a(9){}virtual void print() const { cout<<a;};};class B: public A {char b;public:B( ){b='S';}void print() const {cout<<b;}};void show(A x){ x.print0;}int main(){ Ad1,*p;B d2;p=d2;d1.print();d2.print0;p->print();show(d1);show(d2);return 0;} ” 相关考题
考题
程序的输出结果是【 】。 include using namespace std; class A{ int x; public: A(int
程序的输出结果是【 】。include <iostream>using namespace std;class A{int x;public:A(int x=1):x(x){cout<<x;}};void main(){A a,b(2),c(3);}
考题
下列程序的运行结果是 includeclass Location{private:int X.Y;public:void init(i
下列程序的运行结果是 #include<iostream.h> class Location{ private: int X.Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX( ){ return X;} void valueYA.5 0 6 4B.0 0 6 4C.5 0 6 2D.0 0 6 2
考题
如下程序的输出结果是includevoid fun(int x=y;y=t;}int main(){in
如下程序的输出结果是 #include<iostream> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }A.42,42B.23,23C.23,42D.42,23
考题
下面程序的输出结果是【】。include using namespace std; class base { protected: int
下面程序的输出结果是【 】。include <iostream>using namespace std;class base{protected:int a;public:base(){cout<<"0":}};class basel: virtual public base{public:base1(){ cout<<"1";}};class base2 : virtual public base{public:base2(){cout<<"2";}};class derived : public base1,public base2{public:derived () {cout<<"3"; }}int main (){derived obj;cout<<end1;return 0;}
考题
下列程序的输出结果是【】includeusing namespace std;int qetVar(int *pint){ ren
下列程序的输出结果是【 】include<iostream>using namespace std;int qetVar(int *pint){renurn *pint;}int main (){int a =10;getVar(a) = 20;cout<<a<<end1;return 0; }
考题
下列程序的输出结果是【】 include using namespace std; int get Var(int*pint) {
下列程序的输出结果是【 】include<iostream>using namespace std;int get Var(int*pint){return *pint;}int main(){int a=10;getvar(A) =20;cout<<a<<end1;return 0;}
考题
如下程序的输出结果是includeusing namespace std;class MyClass{public:MyClass(int
如下程序的输出结果是 #include<iostream> using namespace std; class MyClass{ public: MyClass(int i=0){cout<<1;} MyClass(const MyClass&x)}cout<<2;} }; int main( ){ MyClass objl(1),obj2(2),ohj3(objl); return 0; }A.112B.111C.121D.113
考题
下面程序的输出结果是()。include using namespace std;class A {public:A( ) {cout
下面程序的输出结果是( )。 #include <iostream> using namespace std; class A { public: A( ) {cout<<"A";} } class B { public: B() {coat<<"B" ;} } class C: public A { public: B b; C() {cout<<"C";} } void mian(){ C c; }A.CBAB.ABCC.ACBD.BCA
考题
下列程序的运行结果是______。 include class Base { public: virtual void func(int
下列程序的运行结果是______。include<iostream.h>class Base{public:virtual void func(int i){cout<<"class Base:"<<i<<end1;)};class Derived: public Base{public:void func(double d){cout<<"class Derived:"<<d<<endl;}};void main( ){Base a,*p=a;Derived b;p=b;(*p).func(3.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;}
热门标签
最新试卷