个人笔记之 ‘to_string’ is not a member of ‘std’

在linux下

#include 
#include 
using namespace std;
class Tree{
private:
     int ages;
public:
     void set_ages(int age){
         this->ages = age;
     }
     int get_ages(){
         return ages;
     }
     string grow(){
         string s = to_string(ages) + "years";                                                                                         
         return s;
     }
 };
 
 int main()
 {
     Tree t;
     t.set_ages(46);
     cout << "tree:"<<t.grow()<<endl;
     return 0;
 }

编译这段简单的代码时,出现了个问题
gcc tree.cpp -o tree
在这里插入图片描述
使用该命令即可
gcc -std==c++11 tree.cpp -o tree
个人笔记之 ‘to_string’ is not a member of ‘std’_第1张图片

感谢点赞

你可能感兴趣的:(C语言)