数据结构常用算法合集
源代码在线查看: destructor.cpp
//destructor.cpp
#include
#include
const float PI = 3.14159;
class Area
{ private:
int radius;
float area;
public:
Area(); //无参构造函数
Area(int); //1个参数的构造函数
Area(int,float); //两个参数的构造函数
inline float list_area(); //inline的原型
~Area() //析构函数
{ cout };
Area::Area() //构造函数定义
{ radius=0; //清除数据
area=0;
cout }
Area::Area(int _radius)
{ radius = _radius;
area = PI * radius * radius;
cout }
Area::Area(int _radius,float _area)
{ radius = _radius; //设置某一数据
area = _area;
cout }
inline float Area::list_area() //inline函数
{ return area;}
void main()
{ Area circle; //对象声明 circle
cout cout int _radius = 10;
Area circle_1(_radius);
cout cout float _area=PI*_radius*_radius;
Area circle_2(_radius,_area); //对象声明 circle_2
cout getch();
}