开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜