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

题目内容 (请给出正确答案)
若有以下程序:include using namespace std;class A{private:int a;public:void seta

若有以下程序:#include <iostream>using namespace std;class A{private: int a;public: void seta(int x) { a=x; } void showa() { cout<<a<<","; }};class B{private: int b;public: void setb(int x) { b=x; } void showb() { cout<<b<<","; }};class C: public A, private B{private: int c;public: void setc(int x, int y, int z) { c=z; seta(x); setb(y); } void showc() { showa(); showb(); cout<<c<<end1; }};int main(){ C c; c.setc(1,2,3); c.showc(); return 0;}程序执行后的输出结果是( )。

A.1,2,3

B.1,1,1

C.2,2,2

D.3,3,3


参考答案

更多 “ 若有以下程序:include using namespace std;class A{private:int a;public:void seta 若有以下程序:#include <iostream>using namespace std;class A{private: int a;public: void seta(int x) { a=x; } void showa() { cout<<a<<","; }};class B{private: int b;public: void setb(int x) { b=x; } void showb() { cout<<b<<","; }};class C: public A, private B{private: int c;public: void setc(int x, int y, int z) { c=z; seta(x); setb(y); } void showc() { showa(); showb(); cout<<c<<end1; }};int main(){ C c; c.setc(1,2,3); c.showc(); return 0;}程序执行后的输出结果是( )。A.1,2,3B.1,1,1C.2,2,2D.3,3,3 ” 相关考题
考题 下面这个程序的结果是includeclass A{private:int a;public:void seta();int geta( 下面这个程序的结果是 #include<iostream.h> class A { private: int a; public: void seta();int geta();}; void A∷seta() {a=1;} int A∷geta() {return a;} class B { pnvate: int a; publiC: void sera();int geta();}; void B∷seta() {a = 2;} int B∷geta() {return a;} class C:public A,public B { private: int b; public: void display();}; void C∷display() { int b=geta(); cout<<b;} void main() { C c; c.seta(); c.display();}A.1B.2C.随机输出1或2D.程序有错

考题 下列程序的运行结果是【 】。 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 { private: int a; public: void seta( ) ; 下面这个程序的结果是#include<iostream.h>class A{private:int a;public:void seta( ) ;int geta( ) ;};void A: :seta( ){ a=1;}int A: :geta( ){ retum a;}class B{ private:int a;public:void seta( ) ;int geta( ) ;};void B: :seta( ){a=2;}int B: :geta( ){return a;}class C: public A,public B{ private:int b;public:void display( ) ;};void C: :display( ){ int b=geta( ) ;cout < < b;}void main( ){ C c;c. seta( ) ;c. display( ) ;}A.1B.2C.随机输出1或2D.程序有错

考题 若有以下程序:includeusing namespace std;class A{private:int a; public:void seta 若有以下程序: #include<iostream> using namespace std; class A { private: int a; public: void seta(int x) { a=x; } void showa() { cout<<a<<","; } }; class B { private: int b; public: void setb(int x) { b=x; } void showb() { cout<<b<<",”; } }; class C:pUblic A,private B { private: int c; public: void setc(int x,int y,int z) { c=z; seta(x); setb(y); } void showc() { showa(); showb(); cout<<c<<end1; } }; int main() { Cc; c.setc(1,2,3); c.showc(); retrun 0; } 程序执行后的输出结果是A.1,2,3B.1,1,1C.2,2,2D.3,3,3

考题 若有以下程序:includeusing namespace std;class A{private:inta;public:voidseta(in 若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: void seta(int x) { a=x; } void showa() { cout<<a<<","; } }; class B { private: int b; public: void setb (int x) { b=x; } void showb() { cout<<b<<","; } }; class C :public A,private B { private: int c; public: void setc(int x, inc y, int z) { c=z; seta (x); setb (y); } void showc() { showa (); showb (); cout<<c<<end1; } }; int main () { C c; c. setc(1,2,3); c.showc(); return 0; } 程序执行后的输出结果是A.1,2,3B.1,1,1C.2,2,2D.3,3,3

考题 若有以下程序:includeusing namespace std;class A{private:int a;public:A(int i){a 若有以下程序: #include<iostream> using namespace std; class A {private: int a; public: A(int i) {a=i;} void disp() {cout<<a<<“,”;}}; class B {private: int b; public: B(int j {b=j;} void disp() {cout<<b<<A.10,10,10B.10,12,14C.8,10,12D.8,12,10

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

考题 若有以下程序:include using namespace std;class A{private: int a;public: A(int 若有以下程序: #include <iost ream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<", "; } }; class B { private:A.10,10,10B.10,12,14C.8,10,12D.8,12,10

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