ch9_11.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:0k
源码类别:

C#编程

开发平台:

Visual C++

  1. //**********************
  2. //**    ch9_11.cpp    **
  3. //**********************
  4. #include <iostream.h>
  5. bool CircleArea()
  6. {
  7.   double* pd=new double;
  8.   if(!pd){
  9.     cout <<"error memory allocation!";
  10.     return true;
  11.   }
  12.   double& rd=*pd;
  13.   cout <<"the radius is: ";
  14.   cin >>rd;
  15.   cout <<"the area of circle is " <<rd*rd*3.14 <<endl;
  16.   delete &rd;
  17.   return false;
  18. }
  19. void main()
  20. {
  21.   if(CircleArea())
  22.     cout <<"program failed.n";
  23.   else
  24.     cout <<"program successed.n";
  25. }