w*******e 发帖数: 312 | 1 下面的程序为啥还能输出2, b应该不能出test这个函数的啊,何解?
warnign倒是有
warning C4172: returning address of local variable or temporary
#include
int * test(const int & a)
{
int b;
b = a+1;
return &b;
}
int main()
{
int x = 1;
int *y = test(x);
printf("%d",*y);
return 0;
} |
|