65,206
社区成员
发帖
与我相关
我的任务
分享
std::string getString()
{
return “xxxx”;
}
std::string& str = getString(); // ---------------> 此处的临时对象不应该是const std::String& 吗?
str = "YYYY";
std::cout << str << std::endl;
编译通过 输出: YYYY
华丽丽的路过,睡意已解,继续发奋ing。。。
struct test{int i;test(int ii):i(ii){}~test(){cout << '~' << i;}};
test tf() {return 1;}
int main()
{
test& t = tf();
t.i = 2;
cout << t.i;
return 0;
}