title: Accessing subclass functions of member of collection of parent class objects
body: <p>(Refer Update #1 for a concise version of the question.)</p>
  
  <p>We have an (abstract) class named <code>Games</code> that has subclasses, say <code>BasketBall</code> and <code>Hockey</code> (and probably many more to come later).</p>
  
  <p>Another class <code>GameSchedule</code>, must contain a collection <code>GamesCollection</code> of various <code>Games</code> objects. The issue is that we would, at times, like to iterate  only through the <code>BasketBall</code> objects of <code>GamesCollection</code> and call functions that are specific to it (and not mentioned in the <code>Games</code> class).</p>
  
  <p>That is, <code>GameSchedule</code> deals with a number of objects that broadly belong to <code>Games</code> class, in the sense that they <em>do</em> have common functions that are being accessed; at the same time, there is  more granularity at which they are to be handled. </p>
  
  <p>We would like to come up with a design that avoids unsafe downcasting, and is extensible in the sense that creating many subclasses under <code>Games</code> or any of its existing subclasses must not necessitate the addition of too much code to handle this requirement.  </p>
  
  <p>Examples: </p>
  
  <ul>
  <li><p>A clumsy solution that I came up with, that doesn't do <em>any</em> downcasting at all, is to have dummy functions in the <code>Game</code> class for every subclass specific function that has to be called from <code>GameSchedule</code>. These dummy functions will have an overriding implementation in the appropriate subclasses which actually require its implementation.</p></li>
  <li><p>We could explicitly maintain different containers for various subclasses of <code>Games</code> instead of a single container. But this would require a lot of extra code in <code>GameSchedule</code>, when the number of subclasses grow. Especially if we need to iterate through all the <code>Games</code> objects.</p></li>
  </ul>
  
  <p>Is there a neat way of doing this? </p>
  
  <p>Note: the code is written in C++</p>
  
  <p>Update# 1: I realized that the question can be put in a much simpler way. Is it possible to have a container class for any object belonging to a hierarchy of classes? Moreover, this container class must have the ability to pick elements belonging to (or derive from) a particular class from the hierarchy and return an appropriate list. </p>
  
  <p>In the context of the above problem, the container class must have functions like <code>GetCricketGames</code>, <code>GetTestCricketGames</code>, <code>GetBaseballGame</code> etc.,</p>