| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1680 人关注过本帖
标题:[求助]改一个错误
取消只看楼主 加入收藏
W649897
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2006-11-26
收藏
 问题点数:0 回复次数:3 
[求助]改一个错误
//输入三个字符串,按由大到小的顺序输出
//用string的方法
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
string str1,str2,str3;
cout<<"enter three strings:";
getline(cin,str1);
getline(cin,str2);
getline(cin,str3);
void swap(string &,string &);
if(str1>str2)
swap(str1,str2);
if(str1>str3)
swap(str1,str3);
if(str2>str3)
swap(str2,str3);
cout<<str1<<endl<<str2<<endl<<str3<<endl;
return 0;
}
void swap(string&str,string&str4)
{
string temp;
temp=str;str=str4;str4=temp;
}
错误提示
pr02.obj : fatal error LNK1179: invalid or corrupt file: duplicate comdat "?swap@@YAXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z"
搜索更多相关主题的帖子: string swap cin getline include 
2006-12-13 15:31
W649897
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2006-11-26
收藏
得分:0 

谢谢拉

2006-12-17 09:32
W649897
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2006-11-26
收藏
得分:0 

但是如果改到外面去就有14个错误如下
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(49) : error C2065: 'string' : undeclared identifier
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(49) : error C2059: syntax error : ','
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(53) : error C2872: 'string' : ambiguous symbol
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(53) : error C2872: 'string' : ambiguous symbol
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(53) : error C2146: syntax error : missing ';' before identifier 'str1'
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(53) : error C2065: 'str1' : undeclared identifier
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(53) : error C2065: 'str2' : undeclared identifier
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(53) : error C2065: 'str3' : undeclared identifier
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(67) : error C2872: 'string' : ambiguous symbol
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(67) : error C2872: 'string' : ambiguous symbol
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(67) : error C2065: 'str' : undeclared identifier
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(67) : error C2872: 'string' : ambiguous symbol
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(67) : error C2065: 'str4' : undeclared identifier
C:\Documents and Settings\user3_086\My Documents\My eBooks\chapter6\p3.cpp(68) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
Error executing cl.exe.

chapter6.exe - 14 error(s), 0 warning(s)

2006-12-17 09:37
W649897
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2006-11-26
收藏
得分:0 
上面的问题已解决但,提示又说什么该内存不能为written,什么意思呀
2006-12-17 09:41
快速回复:[求助]改一个错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012188 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved