@CrazyHenry
2018-02-04T12:14:28.000000Z
字数 395
阅读 1279
ccccC++Primer
- Author:李英民 | Henry
- E-mail: li
_yingmin@outlookdotcom- Home: https://liyingmin.wixsite.com/henry
快速了解我: About Me
转载请保留上述引用内容,谢谢配合!
string &func(){string s = "Hello";return s;}string s1 = func();//error,无法访问到局部对象s!
const int& func(int);int main(){int s1 = func(2);cout<<s1<<endl;//能正确输出90return 0;}const int& func(int a){int b = 90;return b;}//有一种解释是栈区的局部变量的作用域在函数调用处仍有效
