C/C++返回局部变量的引用/地址

程序1 下面这段程序,返回局部变量的引用,将其赋给指针p,第一次打印能够输出a的值,第二次即是一个随机数:ios #include<iostream> using namespace std; int *p = NULL; int& foo() { int a = 10; return a; } void main() { p=&foo(); cout << *p << endl;
相关文章
相关标签/搜索