c++ builder好,就是好,vc.net太差了

Format_CIH 2003-05-15 05:48:12
请看下面的程序vc.net编译竟然不过,c++ builder就没问题
include <list>
#include <iostream>
using namespace std;

void putvalues(list<string> strlist)
{
cout<<"("<<strlist.size()<<")"<<endl<<"<";
for (list<string>::const_iterator iter=strlist.begin(); iter!=strlist.end();++iter)

cout << (*iter) <<endl;
cout<<">";

}

int main()
{
list<string> strlist;
strlist.push_back("put function declarations in header files");
strlist.push_back("use abstract container instead of built-in arrays");
strlist.push_back("declare class parameters as references");
strlist.push_back("use reference to const types for invariant prarmeters");
strlist.push_back("use less than eight parameters");
putvalues(strlist);
int i;
cin>>i;
}
vc.net的出错信息如下
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::allocator<_Ty>::value_type' (or there is no acceptable conversion)
with
[
_Ty=std::string
]
哪位大侠知道为什么?帮忙
...全文
27 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Format_CIH 2003-05-16
  • 打赏
  • 举报
回复
谢谢thinkx,原来是我太菜,请vc的哥们原谅我的用词不当
ThinkX 2003-05-15
  • 打赏
  • 举报
回复
我猜想的原因是
ostream& operator << (ostream& o, const string& s);
这个函数的处理不同,
Borland的STLPort在<iostream>中实现,而VC的STL在<string>中实现。
不知道标准中有没有关于这方面的规定,如果没有VC也没有错。
再说,其实放在<string>中更合理,因为应该让自定义类型去感知ostream,而没有必要让ostream在<iostream>中去感知其他类型。
Format_CIH 2003-05-15
  • 打赏
  • 举报
回复
谢了,为什么c++ builder没问题?
jruv 2003-05-15
  • 打赏
  • 举报
回复
同意楼上!
ThinkX 2003-05-15
  • 打赏
  • 举报
回复
#include <string>
ydx 2003-05-15
  • 打赏
  • 举报
回复
记者问小泉:什么叫黄军?答:因为我们好色,有慰安妇。什么叫自慰队?没了慰安妇,只好自己解决,就叫自慰队。什么叫日本人?因为自己解决,就是自己日自己,就叫日本人。

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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