Question: Overloading and Templates Overloading the operators < >, =, +, , ==, ||, and && for the class lineType BACKGROUND: -Equation of a line: ax+by=c
Overloading and Templates Overloading the operators <<, >>, =, +, , ==, ||, and && for the class lineType BACKGROUND: -Equation of a line: ax+by=c is the standard equation for a line, where a and b cannot both be zero, and where a, b, and c are real numbers. -Slope of a line: When b != 0 the slope of a line is a/b. When b=0, the line is vertical, and the slope is undefined. When a=0, the line is horizontal, and the slope is zero. -Parallel Lines: Two lines are parallel when they have the same slope, or are both vertical. -Perpendicular Lines: Two lines are perpendicular when one is horizontal and the other vertical, or when the product of their slopes is 1. PROVIDED CLASS lineType -Stores a line: * stores a, the coefficient of x * stores b, the coefficient of y * stores c -Performs operations: * Determines slope of line, if line is non-vertical. * Determines if two lines are equal. * Determines if two lines are parallel. * Determines if two lines are perpendicular. * Determines point of intersection of two lines, if they are not parallel. Tasks: DOWNLOAD zip files corresponding to the class lineType from Blackboard, review the code, and gain an understanding of how it works. 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.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
