How do I ensure assignability within this tree?
<p>There is tree of classes rooted at CBase (single-inheritance). 
CSub is derived from CBase, and other classes derived from CBase or CSub, 
and CBase having virtual member functions. </p>

<p>All classes must be assignable. Some classes have members (pointers) that 
need special treatment in assignment (pointers). 
How do I ensure assignability within this tree of classes ? </p>

<p>First, I thought I need to make "operator=" virtual. 
Then I realized it's wrong. 
Then is this at all possible: </p>

<pre><code>         CBase *x = new CSub; 
         CBase *y = new CSub; 
         *x = *y; // is this okay ?
</code></pre>

<p>If not, how do I assign *y to *x without evil downcast ? I have many 
questions here. </p>

<p>If I need to cast  every time I assign through CBase*, then this does 
not look typesafe, does it ? 
Do I need to insert type checks in  "operator=" to check that lhs and 
rhs have same type ? 
etc etc. Examples are welcome. </p>

<p>Thanks 
Viki</p>
