I have been asked in an interview "Can a Union be self-referenced?"
I know that struct can self-reference, but I'm really confused about union. I've read in one text book that union can self-reference, but it didn't say anything more on the subject.
Can anyone confirm whether a union is or is not able to be self-referenced?
sure it can, really the same way as struct:
union toto {
union toto* a;
unsigned b;
};
as soon as the tag identifier toto is known to be a union type union toto* is a pointer to an incomplete type.
Difficult to figure out that this knowledge will serve you for something else than an interview, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With