我想知道如果我按照以下方式编写代码:
与下面的代码有何不同?
void func(const char *str);
,是否会引用有效的str
。auto str = string("hello").c_str();
func(str);
与下面的代码有何不同?
func(string("hello").c_str())
func(str);
吗? - us2012func("hello");
? :-) - Bo Persson