各位兄弟,我的vc++6.0的而且又按上了MSDN,竟然不能用string,
 比如最简单的 :
    string st="How are you ?";
它也出错?为什么???为什么???为什么???

解决方案 »

  1.   

    string st="How are you ?";
    好象没有string这个类型吧?
    如果你将string 改为 CString 应该没有问题。
      

  2.   

    using namespace XXXXX
    string是定义在stl中的
    哪个namespace忘了,不好意思
      

  3.   

    还是不行,
    但是在我的头文件里有 string.h 好像是用不上,为什么?
      

  4.   

    它说找不到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)
    这两行错误,
      

  5.   

    比方说最简单的:
    #include <iostream.h>
    #include <string>
     using namespace std;
    void main()
    {
    string str ;
    cin>>str;

    cout<<str;
    }
    也不行
    Why????
      

  6.   

    string.h 这个头文件是声明串的处理函数的呀,并没有定义string类、结构等
      

  7.   

    如果声明为string.h它就说这是错的
      

  8.   

    #include <string>int main()
    {
      using namespace std
      sting c;
    }我机器上成功了
      

  9.   

    using namespace std;
    少打了个分号
    这句也可以放在外面
      

  10.   

    // a.cpp : Defines the entry point for the console application.
    //#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;
    }成功了
    再不行我也不知道为什么了
      

  11.   

    不是“stdafx.h"
    是”stdAfx.h"
      

  12.   

    楼上的,晕???
    这样就可以了
    #include <iostream>
    #include <string>using namespace std;main(int argc,char **argv)
    {
    string str;
    str="How are you ?";
    cout<<str<<endl;
    return 0;
    }
      

  13.   

    楼上的,在VC中用string,我当然知道用命名空间。
    我说的头文件,是回答找不到“stdafx.h”文件的问题,看清楚了
      

  14.   

    #include <string>
    using namespace std;
      

  15.   

    把#include <iostream.h>
    改成#include<iostream>
    就行了
    你把c的标准库和c++标准库一起用
    所以编译器无法识别。
    我以前也遇到过!