I\'m having trouble with the inheritance of operator=. Why doesn\'t this code work, and what is the best way to fix it?
#include
class A
{
You cannot assign across the hierarchy like this - B and C are different subclasses of A. You can assign a B to a B or a C to a C but not a C to a B or vice versa.
You probably want to implement operator= in B and C, delegating the A part of the assignment to A::operator= before you try this though. Otherwise the B- and C-specific parts of those classes will get lost in the assignment.