作业帮 > 综合 > 作业

采用静态数据成员和静态成员函数定义一个能够实现对象创建个数跟踪的person类;简单点的,

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/15 01:50:30
采用静态数据成员和静态成员函数定义一个能够实现对象创建个数跟踪的person类;简单点的,
C++编程
class person
{
static int count;
public:
person()
{
count++;
}
person(const person& cpy)
{
count++;
}
person()
{
count--;
}
static int GetCount();
};
int person::count = 0;
int person::GetCount()
{
return count;
}
再问: 主函数里边应该怎么输出呢?