填空题
以下程序运行后的输出结果是
【14】
。
#include <iostream>
#include <string>
using namespace std;
class Y;
class X
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,"stringX");
Y b(20,"stringY");
a. show (b) ;
return O;
【参考答案】
stringX,stringY
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
有如下的程序: #include <iostream> #include <fstream> using namespace std; int main() ofstream outf( D: temp.txt ,ios_base::trunc) ; outf<< World Wide Web ; outf.close(); ifstream inf( D: temp.txt ); char s[20]; inf>>s; inf.close(); cout<<s; return 0; 执行后的输出结果是 【15】 。
点击查看答案&解析
填空题
若有以下程序: #include <iostream> using namespace std; template <class T> T min(T x,T y) if(x<y) return x; else return y; int main() int n1=2,n2=10; double d1=1.5;d2=5.6; cout<<min(n1,n2)<< , ; cout<<min(d2,d2)<<end1; return 0; 程序运行后的输出结果是 【13】 。
点击查看答案&解析
相关试题
下面程序的功能是:将字符数组a中下标值为...
阅读下面程序: #include <iostream>...
若有以下程序: #include <iostream>...
有如下的程序: #include <iostream>...
以下程序执行后的输出结果是 ( )。 #...