源程式:
#include <iostream>
using namespace std;
class CCount //定義類CCount
{
public:
CCount(void); //構造函數
~CCount(void); //析構函數
int GetCount(void); //成員函數
void SetCount(int iCount); //成員函數
private:
int m_iCount; //私有變量
};
//以下定義成員函數
CCount::CCount(void)
{
cout<<"調用構造函數..."<<endl;
};
CCount::~CCount(void)
{
cout<<"調用析構函數..."<<endl;
};
int CCount::GetCount(void)
{
return m_iCount;
}
void CCount::SetCount(int iCount)
{
m_iCount=iCount;
}