Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please implement the following problem in basic C++ code and include detailed comments so that I am able to understand the processes for the solution.

Please implement the following problem in basic C++ code and include detailed comments so that I am able to understand the processes for the solution. Thanks in advance.

image text in transcribed

// Lab17.cpp

 #include  #include  #include  using namespace std; class lineType { //Overload the stream extraction operators friend ostream& operator>(istream&, lineType&); public: const lineType& operator=(const lineType&); //overload the assignment operator void setLine(double a = 0, double b = 0, double c = 0); //Function to set the line. double getXCoefficient() const; double getYCoefficient() const; double getCOnstantTerm() const; void setXCoefficient(double coeff); void setYCoefficient(double coeff); void setConstantTerm(double c); bool operator&&(const lineType& otherLine) const; //returns True if this line is perperdicular to otherLine. lineType(double a = 0, double b = 0, double c = 0); //Constructor private: double xCoeff; double yCoeff; double constTerm; }; //--------------------------------functions implementation--------------------------------------- void lineType::setLine(double a, double b, double c) { xCoeff = a; yCoeff = b; if (a == 0 && b == 0) constTerm = 0; else constTerm = c; } double lineType::getXCoefficient() const { return xCoeff; } double lineType::getYCoefficient() const { return yCoeff; } double lineType::getCOnstantTerm() const { return constTerm; } void lineType::setXCoefficient(double coeff) { xCoeff = coeff; } void lineType::setYCoefficient(double coeff) { yCoeff = coeff; } void lineType::setConstantTerm(double c) { constTerm = c; } lineType::lineType(double a, double b, double c) { setLine(a, b, c); } const lineType& lineType::operator=(const lineType& otherLine) { //Complete me } ostream& operator>(istream& isObject, lineType& line) { //Complete me } //----------------------DriverProgram----------------------- int main() { lineType line1(2, 3, 4); lineType line2(3, 5, 7); lineType line3(2, 3, -2); lineType line4(3, -2, 1); lineType line5; lineType line6; cout > line5; cout  
Question: Download lab17.cpp from the blackboard. In this file, the definition of the class lineType, has given which represents a line equation. In this lab, you are asked to complete the body for two operators overloading function as following 1 Overload the stream extraction operator>> for the input stream The user input should be in (a,be) format where Xcoef-a, 'coef-b and ConstTerm=c variables for the line object. For example, the code cin >> line; should accept (2,3,4) as the line input format 2) Overload the assignment operator to assign a line object into another line object. It will copy all member variables from its right operand to its left operand. For example, linel-line2; will copy all member variables from line2 to the linel object. Then, without changing the main function, execute your program to get the same output. Submit a single cpp file. Output C:WINDOWSlsystem321cmd.exe nel: 2x + 3y 4 line2: 3x + 5y 7 line3 : 2x + 3y = -2 line4 : 3x - 2y 1 Input line5 in the form (a, b, c): (2,3,4) lne5 : 2x + 3y 4 line5 has been copied to line6 by the assignment operator line6: 2x 3y4 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago