#include <iostream>
using namespace std;
#include <string>
class string1:public string
{
public:
string1 &operator~()
{ string1 s2;
for(int i=(*this).size()-1;i>=0;i--)
{
s2+=*((*this).c_str()+i);
}
//s=s2;
*this=s2;
return *this;
};
};
int main(){
string1 s1,s;
cout << "输入字符串s1:" << endl;
s1.c_str();
cin >> s1;
cout << "输出字符串s1:" << endl;
cout<<~s1<< endl;
system("pause");
return 0;
}
using namespace std;
#include <string>
class string1:public string
{
public:
string1 &operator~()
{ string1 s2;
for(int i=(*this).size()-1;i>=0;i--)
{
s2+=*((*this).c_str()+i);
}
//s=s2;
*this=s2;
return *this;
};
};
int main(){
string1 s1,s;
cout << "输入字符串s1:" << endl;
s1.c_str();
cin >> s1;
cout << "输出字符串s1:" << endl;
cout<<~s1<< endl;
system("pause");
return 0;
}
学习需要安静。。海盗要重新来过。。