Converting Derived** to Base** and Derived* to Base*
<p>Ok, I was reading through <a href="http://yosefk.com/c++fqa/inheritance-proper.html#fqa-21.2" rel="nofollow">this entry in the FQA</a> dealing about the issue of converting a <code>Derived**</code> to a <code>Base**</code> and why it is forbidden, and I got that the problem is that you could assign to a <code>Base*</code> something which is not a <code>Derived*</code>, so we forbid that. </p>

<p>So far, so good.</p>

<p>But, if we apply that principle in depth, why aren't we forbidding such example?</p>

<pre><code>void nasty_function(Base *b)
{
  *b = Base(3); // Ouch!
}

int main(int argc, char **argv)
{
  Derived *d = new Derived;
  nasty_function(d); // Ooops, now *d points to a Base. What would happen now?
}
</code></pre>

<p>I agree that <code>nasty_function</code> does something idiotic, so we could say that letting that kind of conversion is fine because we enable interesting designs, but we could say that also for the double-indirection: you got a <code>Base **</code>, but you shouldn't assign anything to its deference because you really don't know where that <code>Base **</code> comes, just like the <code>Base *</code>.</p>

<p>So, the question: what's special about that extra-level-of-indirection? Maybe the point is that, with just one level of indirection, we could play with virtual <code>operator=</code> to avoid that, while the same machinery isn't available on plain pointers?</p>
