What sort of things would make my polynomial class uncopiable? |
It's not a matter of being uncopiable, but rather that the compiler provided copy constructor won't work correctly.
You haven't shown the declaration for your class, so I'm making a few assumptions.
1) You don't have a copy constructor.
2) solution.coeff is a pointer to dynamically allocated memory.
3) Your destructor deallocates the dynamically allocated memory.
Remember that if you don't provide a copy constructor, the compiler will provide one that does a
shallow copy. A shallow copy of a pointer to dynamically allocated memory means that you now have two instances pointing to the same memory. When you delete the dynamically allocated memory in one instance, the pointer in the other instance is not changed and now points to memory that has already been deallocated. Then when the other instance tries to delete that same memory, you get a trap.
In the snippet at line 8 in your OP, what happens to the previous memory allocated to coeff? You have a memory leak here.