#include<iostream.h>
class SimpleCircle
{
public:
SimpleCircle(){
itsRadius=new int;
*itsRadius=5;
};
SimpleCircle(const SimpleCircle & rhs){
itsRadius=new int;
cout<<"SimpleCircle copy constructor..."<<endl;
}
virtual ~SimpleCircle(){
delete itsRadius;
itsRadius=0;
}
int getRadius(){
return *itsRadius;
}
SimpleCircle(int y){
itsRadius=new int;
*itsRadius=y;
}
void SetRadius(int x){
*itsRadius=x;
}
void Increment(){
++itsRadius;
}
void operator =(SimpleCircle & rhs){
*itsRadius = rhs.getRadius();
}
SimpleCircle operator -( SimpleCircle& );
private:
int *itsRadius;
};
SimpleCircle SimpleCircle::operator -( SimpleCircle & rhs)
{
return SimpleCircle(*itsRadius - rhs.getRadius());
}
void main()
{
SimpleCircle a,b(9),c;
a.SetRadius(15);
a.Increment();
b.Increment();
cout <<"a=:"<<a.getRadius()<<" b=:"<<b.getRadius()<<endl;
c=a-b;
cout <<"c=:"<<c.getRadius()<<endl;
}