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

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

若有以下程序:#include<iostream>using namespace std;class A {private: int x;public: int z; void setx(int i) { x=i; } int getx () { return x; }}:class B : public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a) ; z=b; m=c; } void display{) { cout<<getx ()<<", "<<z<<", "<<m<<end1; }};int main(){ B obj; obj. setvalue(2,3,4); obj.display(); return 0;} 程序运行以后的输出结果是

A.产生语法错误

B.2,3,4

C.2,2,2

D.4,3,2


参考答案

更多 “ 若有以下程序:includeusing namespace std;class A{private:int x;public:int z;void 若有以下程序:#include<iostream>using namespace std;class A {private: int x;public: int z; void setx(int i) { x=i; } int getx () { return x; }}:class B : public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a) ; z=b; m=c; } void display{) { cout<<getx ()<<", "<<z<<", "<<m<<end1; }};int main(){ B obj; obj. setvalue(2,3,4); obj.display(); return 0;} 程序运行以后的输出结果是A.产生语法错误B.2,3,4C.2,2,2D.4,3,2 ” 相关考题
考题 有以下程序:includeusing namespace std;class A{private:int a;public:A(int i){a=i 有以下程序: #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 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

考题 程序的输出结果是【 】。 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);}

考题 若有以下程序 include using namespace std; class A {private:int a; public: A(in 若有以下程序 #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<<","; } }; class C: public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp() { A::disp(); B::disp(); cout<<c<<end1; } }; int main() { C obj(10); obj.disp(); return 0; } 程序执行后的输出结果是A.10,10,10B.10,12,14C.8,10,12D.8,12,10

考题 有以下程序:includeusing namespace std;classA{private: int x;public: A(int a) {x 有以下程序: #include<iostream> using namespace std; class A { private: int x; public: A(int a) { x=a; } friend class B; }; class B { public: void print(A a) { a.x--; cout<<a, x<<end1; } }; int main () { A a(10); B b; b.print (a) ; return 0; } 程序执行后的输出结果是( )。A.9B.10C.11D.12

考题 若有以下程序:include using namespace std;class A{private:int x;public:int z;voi 若有以下程序:#include <iostream>using namespace std;class A{private: int x;public: int z; void setx(int i) { x=i; } int getx() { return x; }};class B: public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a); z=b; m=c; } void display() { cout<<getx()<<","<<z<<","<<m<<end1; }};int main(){ B obj; obj.setvalue(2,3,4); obj.display(); return 0;程序运行以后的输出结果是( )A.产生语法错误B.2,3,4C.2,2,2D.4,3,2

考题 若有以下程序:include using namespace std;class A{private:int a;public:A(im i){a 若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A(im i) { a=i; } void disp() cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp0 { cout<<b<<","; } }; class C: public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp0 { A::disp(); B::disp(); cout<<c<<endl; } }; int main() { C obj(10); obj.disp(); return 0; } 程序执行后的输出结果是( )。A.10,10,10B.10,12,14C.8,10,12D.8,12,10

考题 若有以下程序: include usingnamespace std; class Sample { private: const int n; 若有以下程序:include <iostream>using namespace std;class Sample{private:const int n;public:Sample(int i) :n(i) {)void print(){cout<<"n="<<n<<end1;}};int main(){sample a(10);a.print();return 0;}上述程序运行后的输出结果是【 】。

考题 若有以下程序:include using namespace std;class A{private: int x;protected: int 若有以下程序: #include <iostream> using namespace std; class A { private: int x; protected: int y; public: int z; void setx(int i) { x=i; } int getx () { return x; }; class B : protected A { public: void setvalue(int a, int b, int c) { setx (a); y=b; z=c; } void display() { cout<<getx ( ) <<", "<<y<<", "<<z<<", "<<end1; } }; int main () { B obj; obj.setvalue(5, 6, 7); obj.display ( ); return 0; } 程序运行后的输出结果是( )。A.产生语法错误B.7,6,5C.5,6,7D.7,5,6

考题 若有以下程序:include using 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) : d1 (x) { } void dispa() { cout<<d1, x<<", "; } }; class B: public A { private: data d2; public: B(int x) : A(x-1),d2(x) {} void dispb() { cout<<d2.x<<end1; } }; 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 Base{ int x;protected: int y;pub 若有以下程序: #include <iostream> using namespace std; class Base { int x; protected: int y; public: int z; void setx(int i) { x=i; } int getx ( ) { return x; } }; class Inherit : private Base { private: int m; public: int p; void setvalue(int a,int b,int c, int d) { setx(a) ; y=b; z=c; m=d; } void display() { cout<<getx ()<<", "<<y<<", "<<z<<", "<<m<<end1; } }; int main() { Inherit A; A.setvalue(1,2,3,4); A.display(); return 0; } 程序运行后的输出结果是( )。A.1,2,3,4B.产生语法错误C.4,3,2,1D.2,3,4,5

考题 若有以下程序:include using namespace std;class myClass{private: int var;public: 若有以下程序: #include <iostream> using namespace std; class myClass { private: int var; public: myClass(int i) { var=i; } void add() { s+=var; } static int s; void display() { cout<<s<<end1; } }; int myClass::s=0; int main ( ) { myClass a(1),b(2),c(3); a.add(); b.add(); c.dislay(); return O; } 程序执行后的输出结果是( )。A.1B.4C.3D.7

考题 若有以下程序:include using namespace std;class Base{private: int a,b;public: Ba 若有以下程序: #include <iostream> using namespace std; class Base { private: int a,b; public: Base(int x, int y) { a=x; b=y; } void show() { cout<<a<<", "<<b<<end1; } }; class Derive : public Base { private: int c, d; public: Derive(int x, int y, int z,int m):Base(x,y) { c=z; d=m; } void show() { cout<<c<<", "<<d<<end1; } }; int main ( ) { Base b(50,50) ,*pb; Derive d(10,20,30,40); pb=d; pb->show {); return 0; }A.10,20B.30,40C.20,30D.50,50

考题 若有以下程序include using namespace std;class A{public: A(int i,int j) {a=i;b=j 若有以下程序 #include <iostream> using namespace std; class A { public: A(int i,int j) { a=i; b=j; } void move(int x, int y) { a+=x; b+=y; } void show() { cout < <a < <" , " <<b<< end1; } private: int a,b; }; class B : private A { public: B(int i,int j) :A(i,j) {} void fun ( ) { move (3, 5); } void f1 ( ) { A::show(); } }; int main ( ) { B d(3,4); d. fun ( ); d.f1(); return 0; } 程序执行后的输出结果是 ( )。A.3,4B.6,8C.6,9D.4,3

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

考题 如下程序执行后的输出结果是【】。include using namespace std; class Base { public: 如下程序执行后的输出结果是【 】。include <iostream>using namespace std;class Base{public:Base(int x,int y){a=x;b=y;}void Show(){cout<<"Base: "<<a<< ',' <<b<<" ";}private:int a,b;};class Derived : public Base{public:Derived(int x, int y, int z) : Base(x,y),c(z) { }void Show(){cout<<"Derived:"<<c<<end1;}private:int c;};int main(){Base b(100,100),*pb;Derived d(10,20,30);pb=b;pb->Show();pb=d;pb->Show();return 0;}

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

考题 若有以下程序:include using namespace std;class A{private:int a;public:A(int i){ 若有以下程序: #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<<","; } }; class C : public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp () { A::disp(); B::disp(); cout<<c<<endl; } }; int main() { C obj(10); obj.disp(); return 0; }A.10,10,10B.10,12,14C.8,10,12D.8,12,10

考题 若有以下程序:include using namespace std;class Base{private: inta,b;public: Bas 若有以下程序: #include <iostream> using namespace std; class Base { private: int a,b; public: Base(int x, int y) { a=x; b=y; } void disp () { cout<<a<<" "<<b<<end1; } }; class Derived : public Base { private: int c; int d; public: Derived(int x,int y, int z,int m) :Base(x,y) { c=z; d=m; } void disp () { cout<<c<<" "<<d<<end1; } }; int main() { Base b(5,5),*pb; Derived obj(1,2,3,4); pb=obj; pb->disp(); return 0; } 执行程序后的输出结果是( )。A.1,2B.3,4C.2,3D.5,5

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

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

考题 有以下程序:include using namespace std;define PI 3.14class Point{ private:int 有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; }A.314B.157C.78.5D.153.86

考题 若有以下程序:include using namespace std;class datapublic:int x;data(int x) { d 若有以下程序: #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): d1(x){} void dispa() { cout<<d1.x<<","; } }; class B: public A { private: data d2; public: B(int x): A(x-1),d2(x){} void dispb() { cout<<d2.x<<end1; } }; 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 i 若有以下程序: #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<<", "; } }; class C : public B,public A { private: int c; public: C int k) :A(k-2),B(k+2) { c=k; } void disp() { A: :disp (); B::disp(); cout<<c<<end1; } }; int main () { C ebj (10); obj .disp (); return 0; } 程序执行后的输出结果是( )。A.10,10,10B.10,12,14C.8,10,12D.8,12,10

考题 若有以下程序:include using namespace std;class point{private: int x, y;public: 若有以下程序: #include <iostream> using namespace std; class point { private: int x, y; public: point ( ) { x=0; y=0; } void setpoint(int x1,int y1) { x=x1; y=y1;A.12,12B.5,5C.12,5D.5,12

考题 若有以下程序:include using namespace std;class Base{private: int x;protected: i 若有以下程序: #include <iostream> using namespace std; class Base { private: int x; protected: int y; public: int z; void setx(int i) { x=i; int getx () { return x; } }A.1,2,3,4B.产生语法错误C.4,3,2,1D.2,3,4,5

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