linux 下 string 类型 报错解决办法

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;
}

linux 下 string  类型 报错解决办法

相关文章:

你感兴趣的文章:

标签云: