>From what i've read it's not possible
Sure it is. You just have to think squiggly:
Code:
struct node {
int type;
union first {
object obj;
template templ;
}
};
...
void list_add ( list *list, node *item );
Now the client can write application specific makenode functions or you can provide them if you'd like:
Code:
list_add ( mylist, makenode ( TYPE1, new_obj ) );
list_add ( mylist, makenode ( TYPE2, new_templ ) );
Or, you could use a variable length argument list:
Code:
void list_add ( list *list, int type, ... );
...
list_add ( mylist, TYPE1, obj );
list_add ( mylist, TYPE2, templ );
Be creative and you'll see other options as well.
>Is it possible to redeclare a variable
Not within the same scope. But if all you want is to change an int to a char then you have nothing to worry about as long as the int only holds char values. An int can hold all of the values that a char can and provided you use casts when necessary you'll have no problems. The opposite is not true though. You have to be careful when converting int to char because the value may not be representable by a char.