谁给解释下这个比较弱的问题?# Programming - 葵花宝典
w*e
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;
}
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;
}