高手请分析为什么出错

chinaeagle 2002-08-06 01:49:13
#include<iostream>
#include<string>
using namespace std;

int main()
{
string swap(string&,string&);
cout<<"pls input the two string to be swapped"<<endl;
string s1,s2;
cin>>s1>>s2;
cout<<endl;
swap(s1,s2);
cout<<"after swapping,s1 is:"<<s1<<"\ns2 is :"<<s2<<endl;
system("pause");
}

string swap(string &x,string &y)
{
string temp;
temp=x;
x=y;
y=temp;
// return;
}
...全文
162 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
liushmh 2002-08-06
  • 打赏
  • 举报
回复
看来你没有搞清楚函数的情况
netxray 2002-08-06
  • 打赏
  • 举报
回复
你的swap函数不需要返回值,所以把两个string swap(string &x,string &y)都改为void swap(string &x,string &y)

69,379

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧