分类: C/C++
2011-08-03 21:34:39
/*
* 析构函数
* Lzy 2011-8-3
*/
#include
using namespace std;
class Elipse
{
private:
int num;
Elipse *Ee;
public:
Elipse(){cout<<"构造函数!"<
~Elipse(){cout<<"析构函数:"<
void print(){cout<<"---------"<
};
int main(void)
{
Elipse e;
e.print();
return 0;
}
/*
* 析构函数调用顺序
* Lzy 2011-8-3
*/
#include
using namespace std;
class Elipse
{
private:
int num;
public:
Elipse(int i):num(i){cout<<"构造函数:"<
~Elipse(){cout<<"析构函数:"<
};
int main(void)
{
Elipse e1(1),e2(2);
return 0;
}
/*
* 调用析构函数
* Lzy 2011-8-3
*/
#include
using namespace std;
class Elipse
{
private:
int num;
Elipse *Ee;
public:
Elipse(){cout<<"构造函数!"<
~Elipse(){cout<<"析构函数:"<
void print(){cout<<"---------"<
};
int main(void)
{
Elipse e;
e.print();
e.~Elipse();
return 0;
}