Starting from:
$30

$24

Lab 17 Solution




Objectives:




1. Implement operator overloading.




Related math background:




The 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.




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:




Overload the stream extraction operator , for the input stream.



The user input should be in (a,b,c) format where Xcoef=a, Ycoef=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.




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, line1=line2; will copy all member variables from line2 to the line1 object.




Then, without changing the main function, execute your program to get the same output. Submit a single cpp file.



More products