单项选择题
若有以下程序:
#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,2
B.3,4
C.2,3
D.5,5
热门
试题
单项选择题
有以下程序: #include <iostream> using namespace std; class R public: R(int f1,int r2) R1=r1; R2=r2; void print(); void print ()const; private: int R1, R2; ; void R: :print() cout<<R1<< , <<R2<<end1; void R: :print() const cout<<Rl<< , <<R2<<end1; int main () R a(5,4); const R b(20,52); b.print (); return 0; 执行后的输出结果是
A.5,4
B.20,52
C.0,0
D.4,5
单项选择题
有以下程序: #include <iostream> #include <string> using namespace std; class Y; class X private: int x; char *strx; public: X(int a, char *str) x=a; strx=new char[strlen(str)+1]; strcpy(strx,str); void show(Y &ob) ; ; class Y private: int y; char *stry; public: Y(int b,char *str) y=b; stry=new char[strlen(str)+1]; strcpy(stry, str); friend void X: :show(Y &ob) ; ; void X: :show(Y &ob) cout<<strx<< , ; cout<<ob, stry<<end1; int main ( ) X a(10, X ); Y b (20, Y ); a. show(B) ; return 0; 执行后的输出结果是( )。
A.X,Y
B.a,b
C.X,X
D.Y,Y