64,685
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<string>
using namespace std;
class files
{
public:
string a,b;
int c;
public:
void exchange(string a, string b)
{
string d;
d = a;
a = b;
b = d;
return;
}
int len(string a)
{
return a.length();
}
};
int main()
{
files L;
cout << "请输入两串字符串:" << endl << "字符串A=";
cin >> L.a;
cout << "字符串B=";
cin >> L.b;
L.exchange;
cout << "交换后A=" << L.a << endl << "B=" << L.b << endl;
cout << "A的长度为%d" << L.len(L.a) << endl << "B的长度为%d" << L.len(L.b) << endl;
return 0;
}