- 论坛徽章:
- 0
|
为什么我用VC6.0企业版怎么都定义不了字符窜:string?
原帖由 "sdupoplar" 发表:
最好用iostream加上 using namespace std,
这样在别的编译环境也可以,用iostream.h在VC中可以,别的地方不一定可以了,VC中iostream和iostream.h都一样。
我知道vc是用iostream.h的.我定义了一个字符窜,在主函数内最后想输出字符窜,但是不行,出现这样的错误:error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>;,class std::allocator<char>; >;' (or there is no acceptable conversion),为什么会这样?如下:
#include<iostream.h>;
#include<string>;
using namespace std;
void main()
{
string s1="daffaaf";//s1("daffaaf" 也是一样不行
string s2="bsbdbd";
cout<<s1<<endl;
cout<<s2<<endl;
}
书本都是这样这样cout<<s1这样直接输出的啊,为什么不可以?
还有,是不是多少个头文件只一个using就可以了? |
|