单项选择题
有以下程序:
#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