填空题
C++
题号 #4126123
有如下的程序:
#include<iostream>
#include<cstring>
using namespace std;
class rev{
char * s;
public:
rev(const char *s){
this->s=new char[strlen(s)+1];
strcpy(this->s,s);
}
rev(rev &r){
s=new char[strlen(s)+1];
for(int i=0;i<strlen(r.s);i++)s[i]=r.s[strlen(r.s)-1-i];
s[stelen(r.s)]=0;
}
~rev(){delete s;}
friend ostream& operator<<(ostream&,const rev &);
};
ostream& operator<<(ostream &os,contst rev&c){
for(int i=strlen(c.s)-1;i>=0;i--)os<<c.s[i];
return 0;
}
int mian(){
char *p="Hello,world!";
rev hey("hay!");
cout<<rev(p)<<endl;
cout<<rev(hay);
return 0;
}
执行上面的程序将输出。
参考答案
暂无
答案解析
!dlrow,olleH
Hay!
Hay!
你可能感兴趣的试题
A.语法错,不能输出正确结果
B.2 2 2 2
C.2 2 3 3
D.2 2 3 2
