Reputation: 15746
I'm navigating thru class members and I'm trying to find out which data type they are.
class ZObject
{
public:
int a; //0x00
bool b; //0x01
DWORD c; //0x02
DWORD d; //0x03
D3DXVECTOR3 e; //0x04
};
DWORD offset = 0x01;
void PrintDataType( DWORD* pointertozobject )
{
printf( typeid(*(pointertozobject +offset)).name() );
}
I keep increasing offset
by +=0x01
, for each call I do to this function, but it always prints unsigned long
which is the type of pointertozobject
, how can I print the datatype of the class member in that offset? (It doesn't needs to be the pointer, I just need to identify it)
Upvotes: 0
Views: 81
Reputation: 93890
C++ doesn't have that kind of type reflection. As a comment states, the type of your expression is DWORD
so that is the answer you get. The address is meaningless.
In order to find type from structure offset you'd have to construct the table yourself, using offsetOf()
plus typeid()
to manually note the type of each member and its offset. Then you could search the table for the desired offset and find the type.
Upvotes: 1