I use MFC TextOut to put some text on screen as follows
std::string myIntToStr(int number)
{
std::stringstream ss;//create a stringstream
ss << number;//add number to the stream
return ss.str();//return a string with the contents of the stream
}
void MViewClass::DrawFunction()
{
CClientDC aDC(this);
// .. Drawing Code
aDC.TextOut(27, 50, ("my age is " + myIntToStr(23)).c_str());
}
But I get error saying " cannot convert argument 3 from 'const char *' to 'const CString &'".
The documentation for TextOut shows a CString overload. I would like to use CString with TextOut as it allows me to use my myIntToStr converter. Any suggestions?
The code uses
std::string'sc_str, which returnsconst char*, notCString`. Tryor just use CString::Format