张江动漫博物馆:C++程序设计: 编写一个Counter类,对其重载运算符+

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 06:09:37

class Counter
{
//数据 根据具体情况设计数据
private:
int a;
……
public:
int b;
……
//操作
private:
……
public:
Counter operator+(const Counter myCounter)
{
a=a+myCounter.a;
b=b+myCounter.b;
……
//此处根据具体情况编写代码
return this;
};
……
}