I want some example on unions.
How can i create union with switch_type attribute.
And how can i initialize that variable.
i want this program in c++
Thank you
If I understand correctly, the "switch type" you want is some information about the way union's data should be interpreted or which member should be taken in account. If this is you're after, then declare a union inside a structure that have a separate member (not affected by union) that holds that information. I would give here an example of it but I don't understand the next of your requirement - "i want this program in c++". The piece of code I was about to put here I must admit - doesn't have nothing specific to C++.
...or do I had to replace the "struct" I've mention above with "class"?