R
Richard Heathfield
Roman Mashak said:
Your question is: is this valid casting? Type casting is something they
do in Hollywood.
Valid but pointless. You're copying a void * to a void *, and in any
case all object pointer types are compatible with void *, so it's a
doubly pointless cast.
Casting is almost always wrong, and the places where it's right are
rarely the places you'd think.
Yes, although your list is merely notatory - it isn't a container.
Beware of that.
It depends on what you're trying to achieve.
My question is: is this valid type casting
Your question is: is this valid casting? Type casting is something they
do in Hollywood.
n->data = (void *)data;
Valid but pointless. You're copying a void * to a void *, and in any
case all object pointer types are compatible with void *, so it's a
doubly pointless cast.
Casting is almost always wrong, and the places where it's right are
rarely the places you'd think.
Will I be able to add 'data' of 'int', 'long', 'char' etc. types?
Yes, although your list is merely notatory - it isn't a container.
Beware of that.
Is this right approach?
It depends on what you're trying to achieve.