The assignmento I have to write is to Derive a class DistSign from class Distance which contains inches and feet as a protected data, to add unary + or – to the distance. Write no argument and two argument constructor.
Here is my program. I don’t know how to add + operator.
#include<iostream.h>
class Distance
{
protected:
int feet;
float inches;
public:
Distance()
{
feet=0;
inches=0;
}
Distance(int f,float in)
{
feet=f;
inches=in;
}
void display()
{
cout<<"\nfeet:"<<feet;
cout<<"\ninches:"<<inches;
}
};
class DistSign:public Distance
{
public:
DistSign(int f,float in):Distance(f,in)
{}
void operator-()
{
feet*=-1;
inches*=-1;
}