Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!think.com!sdd.hp.com!caen!uflorida!SORROW@MAPLE.CIRCA.UFL.EDU From: sorrow@oak.circa.ufl.edu Newsgroups: comp.lang.c++ Subject: Can you determine what type of object is being passed in a function? Message-ID: <0094A424.3B76DAC0@MAPLE.CIRCA.UFL.EDU> Date: 17 Jun 91 16:06:47 GMT Sender: news@uflorida.cis.ufl.EDU Reply-To: sorrow@oak.circa.ufl.edu Organization: University of Florida CIRCA VAX Cluster Lines: 43 I am writing a game in C++ and am using an object hierarchy like this: Object -> Weapon -> Container -> Armor -> etc. etc. I have some functions, such as for the Character class, that are defined as: int Character :: GetObject ( Object &obj ) { } Is there a way to determine what type of object was passed? The Object class is a pure abstract class. I am currently using a bit mask a la: if (Obj.type&OT_WEAPON) dosomething(); else if (Obj.type&OT_CONTAINER) dosomething(); etc. etc. Anyone have any ideas? Also, I would like the ability for some things to inherity from multiple types of objects: Container -- | ---- Backpack of Shielding | Armor __ Any help would be appreciated. Brian /* Brian Hook -- MS-DOS Programmer for Contract ----------------------------------------------------------------- "Seamus, that's my dog...I saw her today at the reception...sorry, sixTEEN inches....better save the women and children first...but this one goes to 11! ..anymore of that plutonium nyborg?....there can be only ONE!....like a finger pointing to the moon....ease the seat back...one day closer to death */