Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!snorkelwacker!mit-eddie!bu.edu!bu-cs!purdue!mentor.cc.purdue.edu!pur-ee!pur-phy!maxwell.physics.purdue.edu!sho From: sho@maxwell.physics.purdue.edu (Sho Kuwamoto) Newsgroups: comp.lang.c++ Subject: Re: Re^2: Is there a way to tell which derived class an object belongs to? Message-ID: <3062@pur-phy> Date: 5 Feb 90 06:55:11 GMT References: <2815@draken.nada.kth.se> <636@tci.bell-atl.com> <7722@chaph.usc.edu> <645@tci.bell-atl.com> <133@dumbcat.UUCP> Sender: news@pur-phy Reply-To: sho@maxwell.physics.purdue.edu.UUCP (Sho Kuwamoto) Organization: Purdue Univ. Physics Dept., W. Lafayette, IN Lines: 33 In article <133@dumbcat.UUCP> marc@dumbcat.UUCP (Marco S Hyman) writes: >In article <645@tci.bell-atl.com> kempf@tci.bell-atl.com (Cory Kempf) writes: >>>Is there any way you can tell which derived class an object belongs to >>>if it is pointed to by a pointer to its base class? [method involving using a virtual member function returning a unique constant for each class deleted] >Picture a common scenario: > [someone screws up by forgetting to write down the number on a] > [piece of paper. the number is reused. oops] What I'd like to see: 1) A sort of extensible enum. One you could add new members to in separate .h files. addEnum IDEnum {class1ID, class2ID, class3ID}; addEnum IDEnum {classXID, classYID}; I think this would be useful for many applications where a derived class adds functionality to an older class. 2) A "mandatory" virtual. Every derived class *must* redefine this type of method. This is not as useful, but there are a few instances (like this one) where each new class *must* redefine a method. As if C++ weren't a kitchen sink language to begin with... -Sho -- sho@physics.purdue.edu <<-- Now if only I could afford a C++ compiler for my mac... and Apple completely rewrote their ROMs for it... and...