typedef unsigned short USHORT;
#include<iostream>
using namespace std;
class counter {
public:
counter();
counter(USHORT initialvalue);
~counter(){}
USHORT getvalue()const{return value;}
void setvalue(USHORT x){value=x;}
counter operator+(const counter &);
private:
USHORT value;
};
counter ::counter(USHORT initialvalue):
value(initialvalue)
{
}
counter::counter():
value(0)
{
}
counter counter::operator+(const counter&rhs)
{
return counter(value+rhs.getvalue());
}
int main()
{
counter varone(2),vartwo(4),varthree;
varthree=varone+vartwo;
cout<<"varone:"<<varone.getvalue()<<endl;
cout<<"vartwo:"<<vartwo.getvalue()<<endl;
cout<<"varthree:"<<varthree.getvalue()<<endl;
return 0;
}