If you want to accept a pointer to an arbitrary object, then you would want the type to be void *
. However, that would be the end of the function, you can't do anything with a void *
except store it's value or cast it to a pointer to some known object. If you're going to cast it anyway, then you probably know what the object is, so you don't need the void *
.
C++ just doesn't have the same kinds of introspection abilities that Java has. In other words, there's not a convenient way to say something like myObject.getClass().getName()
. The closest thing that I'm aware of is runtime type information (RTTI), which you can see in action here.
The other alternative is to create your own root class, and write your own introspection methods (a lot of C++ frameworks do this).