Question: C++ data structure Quadratic A one-variable quadratic expression is an arithmetic expression of the form ar? + bx+c, where a, b, and c are some
C++ data structure

Quadratic A one-variable quadratic expression is an arithmetic expression of the form ar? + bx+c, where a, b, and c are some fixed numbers (called the coefficients) and x is a variable that can take on different values. Design and implement a class that can store information about a quadratic expression. The default constructor should set all three coefficients to zero, and another member function should allow you to change these coefficients. An overloaded constructor should also be able to take the three coefficients. There should be constant member functions to retrieve the current values of the coefficients. There should also be a member function to allow you to evaluate" the quadratic expression at a particular value of x (i.e., the function has one parameter x, and returns the value of the expression ar? + bx+c). Also overload the following operators (as non-member functions) to perform these indicated operations: // Postcondition: The return value is the // quadratic expression obtained by adding 1/ ql and q2. For example, the c coefficient // of the return value is the sum of ql's c Il coefficient and q2's c coefficient. friend Quadratic operator+(const Quadratic& ql, const Quadratic& q2); // Postcondition: The return value is the Il quadratic expression obtained by // multiplying each of q's // coefficients by the number r. friend Quadratic operator *( double r, const Quadratic& q); Notice that the left argument of the overloaded operator * is a double number (rather than a quadratic expression). This allows expressions such as 3.14 * q, where q is a quadratic expression
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
