Is there any difference in unions from structures - except than memory allocation ?
Is there any difference in unions from structures - except than memory allocation ?
No.
Did you have something specific in mind?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Its just that they appeared like twins to me.
Thank you.
No. Only difference between union and structure is the way they get stored in memory.
I can't recall the behaviour of objects with constructors etc in a union, but basically don't do it anyway.
Not sure if you can inherit from them either.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
I am sure that you cannot inherit from structs and unionsNot sure if you can inherit from them either.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)