while Compiling this code, compiler(both dev c++ and visual studio), return following Errors :
Error 1 error C2801: 'operator []' must be a non-static member
Error 2 error C2673: 'operator []' : global functions do not have 'this'
Error 3 error C2227: left of '->size' must point to
Error 4 error C2065: 'poly' : undeclared identifier
Error 5 error C2228: left of '.get_p' must have class/struct/union
i can't really understand why number 1 and 2 occured! while non of them is true.
You forgot the polynomial:: in the operator[] definition. And also you're returning a reference to a temporary variable, since get_p() returns an int not an int&.