|  |  | In article <7p5uatkfp1lg0lluhftkg2ad9okphd814a@4ax.com> , Peter Popov 
<pet### [at] vip bg>  wrote:
> Lastly, a side question. Are there license-free, public-domain,
> cross-platform examples of polymorphic sorted lists, binary, quad- and
> oct-trees or should I make them myself?
You just use the "polymorphic reference type" - others might call it "a
pointer" :-)
Lets say you have something like this (abbreviated syntax):
  class Base;
  class Building : Base;
  class House : Building;
  class Tower : Building;
  class Garage : Building;
And you want to store all buildings, you just do:
  vector<Building *> buildings;
You can access individual objects in a type safe manner like this:
  House *house = dynamic_cast<House *>(buildings[3]);
If is was a House dynamic_cast returns a valid pointer to a House.  If
not, it return NULL.  Note that dynamic_cast throws exceptions if you
cast references.
     Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf  de
Visit POV-Ray on the web: http://mac.povray.org Post a reply to this message
 |  |