这是我在VC上运行的控制台程序,如何调用这个string?
#include <iostream.h>
#include <string.h>
#include <stdio.h>
void main()
{
    string num;
}
--------------------Configuration: test1 - Win32 Debug--------------------
Compiling...
test1.cpp
E:\PROGRAMS\test1\test1.cpp(6) : error C2065: 'string' : undeclared identifier
E:\PROGRAMS\test1\test1.cpp(6) : error C2146: syntax error : missing ';' before identifier 'num'
E:\PROGRAMS\test1\test1.cpp(6) : error C2065: 'num' : undeclared identifier
Error executing cl.exe.test1.exe - 3 error(s), 0 warning(s)

解决方案 »

  1.   

    using namespace std;orstd::string num;
      

  2.   

    试试
    typedef basic_string<char> string;
      

  3.   

    如果你是想用标准C++的东西,那就应该是
    #include <iostream>  //没有.h
    #include <string>    //没有.husing namespace std;main()
    {
    ...
    }
      

  4.   

    ddddh(叶君临) (  )
    你的方法我试了,不行
      

  5.   

    yym314(小鸟)   你的方法成功了,我知道怎么回事了。
      

  6.   

    string是标准c++的东西
     
    看看c++primer吧 楼主or看看Essentialc++