![]() |
#2
peach54602013-09-01 15:15
|
我刚接触C++,但是关于函数反馈一个引用老是不能够理解,函数返回的引用是谁的引用?
例如下面的这个程序,函数f返回了一个引用temp,那么temp是谁的引用?
#include "iostream"
int main()
{int i=5;
int& f(int);
int n=f(i);
std::cout<<n<<std::endl;
return 0;
}
int& f(int x)
{
int temp;
temp=x*x;
return temp;
}