首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

linux 下 string 类型 报错解决办法

2012-03-21 
linux 下 string类型 报错linux 下c++程序中 使用了 string ttt也包含了头文件 #include string,#inclu

linux 下 string 类型 报错
linux 下c++程序中 使用了 string ttt;也包含了头文件 #include <string>,#include <string.h> ,但 g++ -c 时报错找不到string 类型,我试了一下 最简单的也报错!! 请大虾指点!!
  #include<iostream>  
  #include<string>  
  int main()  
  {  
  string temp = "fdsafdas";  
  cout << temp << endl;  
  }  
   


[解决办法]

加上 std 名称空间

C/C++ code
#include <iostream>      #include <string>int main() {          std::string temp("fdsafdas");    std::cout << temp << std::endl;      }
[解决办法]
C/C++ code
    #include <iostream>           #include <string>         using namespace std;      int       main()           {                           string       temp       =       "fdsafdas";                           cout       < <       temp       < <       endl;           } 

热点排行