主题:string的使用
用vc建立的控制台程序:
#include <iostream.h>
#include <string>
using std::string;
int main()
{
string s;
cin>>s;
cout<<s<<endl;
return 0;
}
运行提示:D:\cpp\02\02.cpp(9) : 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)
D:\cpp\02\02.cpp(10) : 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)
请问怎么解决啊?加using namaspace std;using std::cin之类的也不能运行。谢谢
#include <iostream.h>
#include <string>
using std::string;
int main()
{
string s;
cin>>s;
cout<<s<<endl;
return 0;
}
运行提示:D:\cpp\02\02.cpp(9) : 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)
D:\cpp\02\02.cpp(10) : 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)
请问怎么解决啊?加using namaspace std;using std::cin之类的也不能运行。谢谢