关于引用问题!
#include<iostream>
using namespace std;
float temp;
float fn1(float r)
{
temp=r*r*3.14;
return temp;
}
float fn2(float r)
{
temp=r*r*3.14;
return temp;
}
void main()
{
float a=fn1(5.0); //1:
float y=fn1(5.0); //2:
float &b=y; //float &b=fn1(5.0); 为什么不行?
float c=fn2(5.0); //3:
float x=fn2(5.0); //4:
float &d=x; //float &d=fn2(5.0); 也不行啊?
cout<<a<<endl;
cout<<b<<endl;
cout<<c<<endl;
cout<<d<<endl;
return;
}
谁能说说
1:
2:
3:
4:
四种情况各变量在内存中的活动情况
何时创建又何时消失