Search code examples
c++constantscstring

Can CString::Format() receive const std::string?


Can CString::Format() receive const std::string?

Example:

void some_func( const std::string a_string )
{
    CString b_string("World");

    CString c_string;
    c_string.Format("%s %s!", a_string, b_string);

    /* print c_string */
};

Solution

  • No. You need to use the return value from a_string.c_str() (which is a const char* that CString can understand).