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 */
};
No. You need to use the return value from a_string.c_str()
(which is a const char*
that CString can understand).
You can convert the std::string
to a CString:
CString a_cstring( a_string.c_str() );
Then use a_cstring.
c_string.Format("%s %s!", a_cstring, b_string);
精彩评论