

It has the exact same caveat your static version had though: calling GetTitleColor() again will make the previously returned pointer invalid. It remains valid until it goes out of scope (as opposed to your static char* which gets overwritten if you call GetTitleColor on another character).Īnd if you really have no other choice, you can always do the same thing you were doing with a static: replace the return line with those two: static std::string result = buffer.str() You can use the returned string however you like. Std::string colorA = m圜har.GetTitleColor() // straightforwardĪuto colorB = m圜har.GetTitleColor() // better, color gets automatic type from method return typeĬonst auto & colorC = m圜har.GetTitleColor() // if we won't modify it, even better. Its use is very simple: // Assuming m圜har is a CHARACTER instance Because in C++ strings are std::string, not char*. Since it seems to cause a bit of confusion, I want to state that I purposefully changed the return type to be a std::string. 107 1 1 gold badge 2 2 silver badges 9 9 bronze badges.

(And rename that class, you don't want to use all-caps for anything but macros in a C++ program). But now i want to use a seekbar that have only the HEX value for HEX to RGB converter.But I dont find the right function, What Ive to do android-studio Share. Adapt formatting at will: drop the flags if you want decimal, remove the setw and fill if you don't need leading 0. This will write each color as a2-digit hex number. Why don't you use C++ tools? std::string CHARACTER::GetTitleColor() constīuffer.flags(std::ios_base::hex | std::ios_base::left) īuffer <<"r: " <