In C#, every object that can be identified by a reference starts with the same kind of header which includes information about its type, whether it has been associated with a monitor lock, etc. This makes it possible to have methods that can receive any kind of references and perform certain actions upon the objects identified thereby without having to know or care about the types of the references.
In C++, it is possible to have types which don't have any header--just raw data. Some such types are called PODS (Plain Old Data Structures) and can support some operations that could not be done safely with other types. There is no general concept, however, of objects that share a common style of header. Even though many non-PODS types do support at least one common feature that would require some kind of header (the ability to check whether a base-class pointer can be safely cast to a derived-class object) there is no guarantee that the header contain information sufficient to uniquely identify an object's class. If X1
and X2
both derive from X0
, and likewise Z1
and Z2
from Z0
, an implementation could simply store 0 in the header for X0
and Z0
), 1 for X1
and Z1
, and 2 for X2
and Z2
. Since an X0*
couldn't be possibly identify an Z1
, and a Z0*
couldn't identify an X1
, there's no need to have the header distinguish between X1
and Z1
.
Because there is no standard header that can uniquely identify the type of an object, there is no general way to have a function receive a pointer to an object of arbitrary unknown type and do anything useful with it.