单项选择题
有以下程序:
#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
热门
试题
单项选择题
若有以下程序: #include <iostream> using namespace std; int main() int a[4] [4] = 1,2,3,-4,0,-12,-13,14, -21,23,0,-24,-31,32,-33,0; int i,j,s = 0; for(i=0;i<4;i++) for(j=O;j<4;j++) if(a[i] [j] >=0) continue; s+=a [i] [j]; cout<<s<<end1; return 0; 执行后的输出结果是( )。
A.-138
B.141
C.75
D.-1