-1

Possible Duplicate:
Finding the type of an object in C++

... Without using some kind of magic value ID? Are there any language features or maybe some techniques that allow me to do that?

Community
  • 1
  • 1
Paul Manta
  • 30,618
  • 31
  • 128
  • 208
  • That depends on what you're trying to do. If you want to tell if your object is of a certain type, then @miku's link is good. If you want to get the type name of an arbitrary object, there's `typeid` (include `` first). – C. K. Young Jun 13 '11 at 12:39
  • http://en.wikipedia.org/wiki/Run-time_type_information – red-dirt Jun 13 '11 at 12:43

2 Answers2

0

Why would you want to do that ?? In any case, just given a void * it is not possible to find out what type the object is atleast in C++. The QueryInterface pattern came into existense for this and other reasons in the COM model.

kernelman
  • 41
  • 2
  • 15
0

There's always typeid. But what exactly are you trying to do? The results of typeid( object ).name() are implementation specified, and whether they're useful for what you're trying to do or not depends on what you are trying to do, and which implementation you're using. (You can use a wrapper around typeid( object ) as a key into a map.)

James Kanze
  • 150,581
  • 18
  • 184
  • 329