string st="How are you ?"; 好象没有string这个类型吧? 如果你将string 改为 CString 应该没有问题。
using namespace XXXXX string是定义在stl中的 哪个namespace忘了,不好意思
还是不行, 但是在我的头文件里有 string.h 好像是用不上,为什么?
它说找不到stl;我好像记得是在std中; 我用了 using namespace std; 其中我用的头文件是<iostream.h>和<string> 错误信息中有 : 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)和 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) 这两行错误,
好象没有string这个类型吧?
如果你将string 改为 CString 应该没有问题。
string是定义在stl中的
哪个namespace忘了,不好意思
但是在我的头文件里有 string.h 好像是用不上,为什么?
我用了 using namespace std;
其中我用的头文件是<iostream.h>和<string>
错误信息中有
: 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)和
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 str ;
cin>>str;
cout<<str;
}
也不行
Why????
{
using namespace std
sting c;
}我机器上成功了
少打了个分号
这句也可以放在外面
//#include "stdafx.h"
#include <string>
#include <iostream>
#include <conio.h>
using namespace std;int main(int argc, char* argv[])
{
string c("aaa");
cout << c;
getch();
return 0;
}成功了
再不行我也不知道为什么了
是”stdAfx.h"
这样就可以了
#include <iostream>
#include <string>using namespace std;main(int argc,char **argv)
{
string str;
str="How are you ?";
cout<<str<<endl;
return 0;
}
我说的头文件,是回答找不到“stdafx.h”文件的问题,看清楚了
using namespace std;
改成#include<iostream>
就行了
你把c的标准库和c++标准库一起用
所以编译器无法识别。
我以前也遇到过!