A
Alfonso Morra
Straight of the bat, I'll admit this is not a nice solution, it is
dangerous (not type safe) etc,etc, I know what the perils are. I don't
need a lecture on why what I'm doing is perilous - that is not what I'm
after, I want to know *how* I can do it, not *why* I should not do it.
I have an opaque abstract data type that has a void* (yes I know its
ugly) as one of its members (actually the member is a union - but that's
is of little consequence here). I want to be able to use the void
pointer to store different things - including pointers to objects -
based on information stored elsewhere, I am always able to ascertain
what the void* is pointing to and cast it appropriately (I know about
the evils of c-style casts and static casts - but still, bear with me).
I suspect that a pointer is a pointer (nothing more or less) and that I
should be able to store pointers to an object as void* (however abhorent
it may seem to purists). Finally, if I need to return a pointer to an
object, do I return "this" or "*this"?
I look forward to informed responses
dangerous (not type safe) etc,etc, I know what the perils are. I don't
need a lecture on why what I'm doing is perilous - that is not what I'm
after, I want to know *how* I can do it, not *why* I should not do it.
I have an opaque abstract data type that has a void* (yes I know its
ugly) as one of its members (actually the member is a union - but that's
is of little consequence here). I want to be able to use the void
pointer to store different things - including pointers to objects -
based on information stored elsewhere, I am always able to ascertain
what the void* is pointing to and cast it appropriately (I know about
the evils of c-style casts and static casts - but still, bear with me).
I suspect that a pointer is a pointer (nothing more or less) and that I
should be able to store pointers to an object as void* (however abhorent
it may seem to purists). Finally, if I need to return a pointer to an
object, do I return "this" or "*this"?
I look forward to informed responses