ch9_6.cpp

来自「本文档是(作者:钱能)《C++程序设计教程》系列的部分辅助代码。 选题编辑:张」· C++ 代码 · 共 31 行

CPP
31
字号
//*********************
//**    ch9_6.cpp    **
//*********************

#include <iostream.h>

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& b=fn1(5.0);     //2:warning
  float c=fn2(5.0);      //3
  float& d=fn2(5.0);     //4
  cout<<a<<endl;
  cout<<b<<endl;
  cout<<c<<endl;
  cout<<d<<endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?