Related questions with answers

Question

Design the class linetype to implement a line so that the class lineType:

  1. Overloads the stream insertion operator, <<<<, for easy output.
  2. Overloads the stream extraction operator, >>>>, for easy intput. (The line ax+by=ca x+b y=c is input as (a,b,c)(a, b, c).
  3. Overloads the assignment operator to copy a line into another line.
  4. Overloads the unary operator ++, as a member function, so that it returns true if a line is vertical; false otherwise.
  5. Overloads the unary operator -, as a member function, so that it returns true if a line is horizontal; false otherwise.
  6. Overloads the operator ====, as a member function, so that it returns true if two lines are equal; false otherwise.
  7. Overloads the operator | |, as a member function, so that it returns true if two lines are parallel; false otherwise.
  8. Overloads the operator &&\& \&, as a member function, so that it returns true if two lines are perpendicular; false otherwise. Write a program to test your class.

Solution

Verified
Answered 2 years ago
Answered 2 years ago
Step 1
1 of 7

Setup:

#include

using namespace std;

class lineType{ public: bool vertical() const; void slope(); bool equal(lineType) const; bool parallel(lineType) const; bool perpendicular(lineType) const; void intersection(lineType); void printSlope() const; void printIntersection() const; lineType(float = 0.0, float = 0.0, float = 0.0);

    friend ostream& operator << (ostream& osObject, const lineType& cObject);
    friend istream& operator >> (istream& isObject, lineType& cObject);

    const lineType& operator = (const lineType&);

    bool operator + ();
    bool operator - ();

    bool operator == (const lineType& b);

    bool operator || (const lineType& line);
    bool operator && (const lineType& line);

private:
    float a;
    float b;
    float c;
    float sl;
    float xi;
    float yi;

};

Create an account to view solutions

Create an account to view solutions

More related questions

1/4

1/7