I have noticed that when using the default copy assignment for a virtual polymorphic class, I do not get the behaviour I expect. Although copy assignment of the derived class works fine, copy assignment of the parent class does not. See below to a sketch of an example. Why is there a difference?
Code:
struct trace
{
virtual trace* copytype() = 0 ;
...
} ;
struct intersection: public trace // has no copy assignment operator
{
Polynomial<long double> P ; // has copy assignment operator
...
} ;
...
trace* T = this ;
trace* X = dynamic_cast<intersection*>( T->copytype() ) ;
...
// below works - X.P is copied to T.P
*this = *( dynamic_cast<intersection*>(X) ) ;
// below fails - X.P is not properly copied to T.P
*T = *X ;