MODIFY class lineType to use overloaded operators as follow
• MODIFY class lineType to use overloaded operators as follows:
– Overload the stream insertion operator, <<, for output.
– Overload the stream extraction operator, >>, for input.
* The input should be (a,b,c) for line output should be ax+by=c.
– Overload the assignment operator, =, to copy a line into another line.
– Overload the unary operator + so that it returns true if a line is vertical and
false if the line is not vertical.
– Overload unary operator - so that it returns true if a line is horizontal and
false if the line is not horizontal.
Overload the operator == so that it returns true if two lines are equivalent and
false if the two lines are not equivalent.
* Two lines are equivalent when a1 =ka2, b1 =kb2, and c1 =kc2 for any real number k.
– Overload the operator || so that it returns true if two lines are parallel and false if the two lines are not parallel.
–Overload the operator && so that it returns true if two lines are perpendicular and false if the two lines are not perpendicular.
Submit a single cpp file.
– Notes for Modifications:
One approach is to use the code provided in the original functions
of the class lineType for the overloaded operators that are to perform the
same operations. Another way is to call those functions inside the operator definitions.
Use the provided driver program to get the same output.
Solution
friend ostream& operator<<(ostream &out,const lineType &line)
{
out<<line.a;
out<<\"x+\"<<line.b<<\"y=\"<<line.c;
return out;
}
friend istream& operator>>(istream &in,lineType &line)
{
cout<<\"Enter a:\";
in>>line.a;
cout<<\"Enter b:\";
in>>line.b;
cout<<\"Enter c:\";
in>>line.c;
return in;
}
const lineType & operator=(const lineType &line)
{
if(this!=&line)
{
a=line.a;
b=line.b
c=line.c
}
return *this;
}
boolean operator+(const lineType &line)
{
if(std::equal(line.b,0))
return true;
else
return false;
}
boolean operator-(const lineType &line)
{
if(std::equal(line.a,0))
return true;
else
return false;
}
boolean operator==(const lineType &line1,const lineType &line2)
{
if(std::equal((line1.a/line2.a),(line1.b/lin2.b)))
{
if(std::equal((line1.b/line2.b),(line1.c,line2.c)))
return true;
else
return false;
}
else
return false;
}
boolean operator||(const lineType line1,const lineType line2)
{
if(std::equal((-line1.a/line1.b),(-line2.a,line2.b)))
return true;
else
return false;
}
boolean operator&&(const linrType &line1,const lineType &line2)
{
float x;
x=(-line1.a/line1.b)*(-line2.a/line2.b);
if(std::equal(x,-1))
return true;
else
return false;
}


