In this exercise we work with C++'s operator overloading facility, with
copy constructors, and with move constructors. We redesign and reimplement the
polynomial class of exercise 9, making it both easier to use and
more efficient.
File /cse/courses/cse333/13au/ex11.tar.gz contains skeleton
files for this exercise.
You're provided with a complete specification of the Poly class interface, as file Poly.h.
(That file also contains implementation tips, so be sure to read through it.)
File Poly.cc contains code implementing the public toString method, as well
as a private helper function, but all other methods are missing. Your job is to implement
them. You're given a complete mainline, as file ex11.cc, that uses many (but
not all) of the Poly methods.
Finally, you're given a makefile. Command make run will
try to build and run the code, disabling the C++ optimization that elides some
constructor invocations. Command make run-opt will build and run, allowing
that optimization. (make check and make check-opt run
valgrind on your executable.)
Once your code is working, the supplied mainline should produce output like this:
$ make run ./ex11 f = x + 1 f(2) = 3 (Move constructor) (Move constructor) g = x^2 + 2x + 1 g(2) = 9 (Copy constructor) (Copy assign) (Move constructor) (Move assign) h = x^3 + 3x^2 + 3x + 1 h(10) = 1331(The copy and move constructors and assign operators print messages when they're invoked, but the other printing is done by the mainline.)
Note that we will grade your submissions using a mainline different from the one distributed, directly calling each of the methods and checking that the result is correct.
Your code must: