Overloading Operators & Polynomials - C++
Imagine you are given this polynomial x + 2x^2 and you want to subtract it by 2. How can you do this using the operator minus overloading ?
My guess would be:
1 2 3 4
|
Polynomial Polynomial::operator-(Polynomial object1, double constant){
object1[0]-= constant;
return object1;
}
|
Note: I am using the class Polynomial. And the program is a header file .h , not .cpp.
Last edited on
Topic archived. No new replies allowed.