析构函数,构造函数

#include<iostream.h>
class test
{
	int a,b;
public:
	test(int x,int y)
	{
		a=x;
		b=y;
		cout<<"调用构造函数test()"<<endl;
	}
	void print()
	{
		cout<<"两数相减得"<<a-b<<endl;                                    
	}
	~test()
	{
		cout<<"调用析构函数test()"<<endl;
	}
};
void main()
{
	int a1,b1;
	cout<<"请输入两个数"<<endl;
	cin>>a1>>b1;
	test t(a1,b1);
	t.print();
}

原文地址:https://www.cnblogs.com/zztong/p/6695328.html