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

题目内容 (请给出正确答案)
若有如下程序:includeusing 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,4

B.6,8

C.6,9

D.4,3


参考答案

更多 “ 若有如下程序:includeusing 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 ” 相关考题
考题 有如下程序: include using namespace std; int main(){ int sum; 有如下程序: #include<iostream> using namespace std; int main(){ int sum; for(int i=0;i<6;i+=3){ sum=i; for(int j=i;j<6;j++)sum+=j; } cout<<sum<<end1; return 0; } 运行时的输出结果是( )。A.3B.10C.12D.15

考题 有以下程序: include using namespace std; class sample {int x; public:void setx( 有以下程序:include <iostream>using namespace std;class sample{int x;public:void setx(int i){x=i;}int putx (){return x;}};int main ( ){sample *p;sample A[3];A[0] .set>:(5);A[1] .setx(6);A[2] .setx(7);for (int j=0;j<3;j++){p=A[j];cout<<p->putx () <<", ";}cout<<end1;return 0;}执行后的输出结果是【 】。

考题 有如下程序:includeusing namespace std;Class TestClass{private:int x,y;public:Te 有如下程序: #include<iostream> using namespace std; Class TestClass { private: int x,y; public: TestClass(int i,int j) { x=i; y=j; } void print() { cout<<“print1”<<endl; } void print()const { cout<<”prinA.printlB.print2C.printl print2D.程序编译时出错。

考题 有以下程序: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{ public: A(){a=b=2;} 程序的输出结果是【 】。include <iostream>using namespace std;class A{public:A(){a=b=2;}A(int i,int j){a=i;b=j;}void display(){cout<<a<<b;}private:int a,b;};void main(){A m,n(4,8);m.display();n.display();}

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

考题 有以下程序: include using namespace std; int main() {int i=010,j=10;cout 有以下程序:include <iostream>using namespace std;int main(){int i=010,j=10;cout<<(++i)<<","<<i--<<end1;return 0;}则该程序运行后的输出结果是【 】。

考题 若有以下程序: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 using namespace std;class A{public: A(int i,int j) { a=i; b= 有以下程序: #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 fl () { A::show(); } }; int main() { B d(3,4); d.fun(); d.f1(); return 0; } 程序执行后的输出结果是A.3,4B.6,8C.6,9D.4,3

考题 有如下程序:include using namespace std;class sample{private: int x, y;public: s 有如下程序: #include <iostream> using namespace std; class sample { private: int x, y; public: sample(int i,int j) { x=i; y=j; } void disp() { cout<<"displ"<<end1; } void disp() const { cout<<"disp2"<<end1; } }; int main () { const sample a(i,2); a.disp (); return 0; } 该程序运行后的输出结果是( )。A.disp1B.disp2C.disp1 disp2D.程序编译时出错

考题 有如下程序:include using namespace std;int s=0;class sample { static int n;publ 有如下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } };A.2B.5C.7D.3

考题 设有如下程序: include using namespace std; class A { public:int i;display(){co 设有如下程序: #include <iostream> using namespace std; class A { public: int i; display() { cout<<"class A\n"; } }; class B { public: int i; display() { cout<<"class B\n"; } }; class C : public A, public B { int j; public: int i; show ( ) { j = i * i; display(); } }; int main() { C demo; demo.show(); return O; } 则主程序运行时将( )。A.因为变量i的重复定义而报错B.因为对象demo间接调用display()函数时产生二义性而报错C.因为类定义的语法错误而不能运行D.没有语法错误,能够正常输出结果

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

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

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

考题 若有以下程序: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 TestClass{private:int x,y;public:Te 有下列程序: #include<iostream> using namespace std; class TestClass { private: int x,y; public: TestClass (int i,int j) { x=i; y=j; } void print() { cout<<"printl"<<endl; } voA.print1B.print2C.pfint1 print2D.程序编译时出错

考题 若有以下程序:includeusing 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<<endl; } private: int a,b; }; class B:private A { public: B(int i,int j):A(i,j){} void fun() { move(3,5); } void fl() { A::show(); } }; int main() { B d(3,4); d.fun(); d.fl(); return 0; } 程序执行后的输出结果是( )。A.3,4B.6,8C.6,9D.4,3

考题 若有以下程序:include using namespacestd;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 obj (10); obj.disp(); return 0; } 程序执行后的输出结果是A.10,10,10B.10, 12,14C.8,10,12D.8,12,10

考题 若有以下程序: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 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 B{private: int a,b;public: B(){} B 有以下程序: #include <iostream> using namespace std; class B { private: int a,b; public: B(){} B(int i,int j); void printb(); }; class A { B C; public: A(){} A(int i,int j); void printa(); }; A::A(int i,int j) :c(i,j) {} void A::printa() { c.printb (); } B::B(int i, int j) { a=i; b=j; } void B: :printb() { cout<<a<<", "<<b<<end1; } int main () { A m(7,8); m.printa(); return 0; } 该程序运行后的输出结果是( )。A.5,6B.7,8C.8,9D.9,10

考题 有如下程序:include using namespace std;class Base{ protected: int i;public: int 有如下程序: #include <iostream> using namespace std; class Base { protected: int i; public: int j; }; class Derived:public Base {int m; public: int n; }; int main() { Derived d; d.i=0;//[1]d.j=0;//[2]d.m=0;//[3]d.n=0;//[4]return 0; } 其中主函数中有两个赋值语句有错,这两个错误的赋值语句是______ 。A.[1]和[2]B.[1]和[3]C.[2]和[3]D.[2]和[4)

考题 若有以下程序include using namespace std;class A {public: A(int i,int j) {a=i;b= 若有以下程序 #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 fl() { A::show(); } int main() { B d(3,4); d. fun(); d.fl(); return 0; } 程序执行后的输出结果是A.3,4B.6,8C.6,9D.4,3

考题 有如下程序:include using namespace std;classBase{protected:int i:public:int j 有如下程序: #include <iostream.h> using namespace std; class Base { protected: int i: public: int j; }; class Derived: public Base { int m: public: int n; } int main() { Derived d: d.i=0; //[1] d.J=0; //[2] d.m=0; //[3] d.n=0: //[4] return 0; } 其中主函数中有两个赋值语句有错,这两个错误的赋值语句是A.[1]和[2]B.[1]和[3]C.[2]和[3]D.[2]和[4]

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