首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

C++ string有关问题

2012-09-12 
C++ string问题C/C++ code#include iostream#include cstringusing namespace stdint main(){string

C++ string问题

C/C++ code
#include "iostream"#include "cstring"using namespace std;int main(){    string str = "switch";    cout <<str <<endl;    return 0;}


编译报错: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)

难道VC6.0中cout函数不支持string类型的输出

[解决办法]
包含的头文件错了:
C/C++ code
#include <string> //std::string
[解决办法]
探讨

哪头文件string和csring有什么区别,如何选择用哪个.

[解决办法]
探讨
引用:
包含的头文件错了:

C/C++ code

#include <string> //std::string

而不是

C/C++ code


#include <cstring> //包含c的字符串处理函数, 比如strlen


1.改成string问题解决,哪么该如何选择用哪个头文件?
2.我用cstring头文件时,改用print……

热点排行