Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Question on Unions in C

Name: Anonymous 2012-06-24 2:12

So, I know that a pointer is a variable that stores a memory address (basic 4 or 8 bytes). If I place a pointer in a Union type, does the memory address stored by the pointer share the same memory space as the other types, or does the data at the memory address share the same memory?

Or, in other words, if I union a double and a char*, will I memory leak/segfault if I assign the double to anything?

Name: Anonymous 2012-06-24 18:51

>>16
That is true, and it was an apt use of unions to highlight desirable behavior.

>>17
It is unnecessary to waste timing trying to fix something that isn't broken, if you want polymorphism you use vtables and selectors, then adding, modifying or removing a type does not mandate change of code in any other area of your program/library.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List