Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22016

Centos7 g++ "to_string is not in a member of std"

$
0
0

I have some pretty standard C++ code, in which I am using to_string to add a sting and an int together, like this:

#include <string>
using namespace std;

class Color{
public:
    int red, blue, green;

    Color(int r, int g, int b){
        red = r;
        green = g;
        blue = b;
    }

    string to_string(){
        string color = "(" + std::to_string(red) + ", " + std::to_string(green) + ", " + std::to_string(blue) + ")";
        return color;
    }

    string colorize(string text){
        string styled = "\033[38;2"+std::to_string(red)+";"+std::to_string(green)+";"+std::to_string(blue)+";177m"+"\n"+text+"\n"+"\033[0m";
        return styled;
    }

};

When I try to compile this using g++ on Centos7, I get the error "to_string is not in a member of std". What do I need to do? Why is this not working? I'm running the build command g++ main.cpp

I’m running gcc version 4.8.5


Viewing all articles
Browse latest Browse all 22016

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>