cpp c style struct casting
// Example program
#include <iostream>
//pointer struct casting in C++ with c style casts
#define Base_HANDLE int type;
struct Base
{
Base_HANDLE
};
struct IntObj
{
Base_HANDLE
long value;
};
void printType(Base* b)
{
std::cout << b->type << std::endl;
}
int main()
{
IntObj* i = new IntObj();
i->value = 6;
i->type = 2;
Base* b = (Base*)i;
printType(b);
delete i;
}