How to return different classes from one function?
<p>I have a question, though it is not limited to C++. How to return totally different class from one function? </p>

<pre><code>f() {

in case one: return A;
in case two: return B;
in case three: return C;


}
</code></pre>

<p>For example, I have two balls in the space, according to the position and the size, there are three situations for the two balls to intersect with each other, i.e, non-intersection, at point, a and circle. How can I return different class in one function?</p>

<p>Thanks.</p>
