Implicit upcasting question
<p>I find when writing functions (that use function overloading) that accept either a main class or subclass argument, that often implicit upcasting will occur (the subclass is upcasted as the main class and the main class function called). I don't want this implicit upcasting to occur as it means subtle bugs sneak in and cause problems later on down the line.</p>

<p>I have searched on google for information on this, but there is little coherent information I can make use of and only indirect references to it.</p>

<p>How do I disable, stop or prevent implicit upcasting (and even downcasting) from occurring?</p>

<p>(I can't supply any example code as this is a general problem that occurs from time to time).</p>

<p>No, this isn't to do with methods (I would have specified methods) but functions.</p>

<p>No example code, but pseudo idea:
    void Function(BaseClass &amp;A);
    void Function(SubclassClass &amp;B);</p>

<pre><code>Function(ASubclass); //Implicit upcasting occurs, calls BaseClass instead
</code></pre>

<p>The above situation won't happen conventionally (say that the SubclassClass function gets knocked out/erased), but Subclass will be upcast to the BaseClass for use with the BaseClass function, instead of, say, reporting an error or generating a warning - either would be helpful as I don't want implicit upcasting to occur.</p>

<p>Please don't confuse upcasting with non-virtual method calls.</p>
