Vyacheslav Kononenko said:
Oh I am sorry, I've completely lost.
OK looks like we started again. Any data type is polymorphic in such
definition, isn't it? For example we can use "char" as an offset to a
object of some type in the array. Any data type is a number by nature
and what that number means only determined by how we use it. So I don't
see the way you can make a definition of polymorphic data type by what
it can hold. It can hold a set of bits and nothing more.
In principle you already phrased what I meant: "In their definition MS
developers mean a
polymorphic data type as data type which is intended to be cast to other
types (properly or not which is another big question)" ?
You can use a reinterpret_cast to cast a pointer to an integral type and
back again, without changing the value of the pointee. The only requirement
is that the integral type is large enough. This is something which is
commonly done under Windows. For example think of the following situation,
which is not OS specific. You´re implementing a listbox and want to provide
a mechanism that the users can attach whatever objects they have created to
an item in the listbox. However, you do not know anything about the objects
because they have not been implemented at the time you´re writing your GUI.
So what you need is a generic pointer (which equals a polymorphic data
type). This is exactly what is done with the MFC listbox classes where the
user can attach his objects by casting them to DWORD pointers. Consequently
the polymorphic data type is not a data type in the common sense like
int/double/etc, but rather a generic pointer which can be used to store
pointers to objects of whatever types you like. Naturally, you´ll loose the
original type information by the cast & have to recast correctly before
accessing the pointee.
Cheers
Chris