What’s a simple but non-trivial example of class defined using union in C++?
- the class should be defined using
union - the class should have constructor(s) and destructor explicitly declared and implemented
- the class should have methods that demonstrate the difference of such a class from a class defined using
classkey word
Maybe something like this:
I’m assuming here that
TagOnly,SandTshare the common initial segmentEActive. (It might be smarter to stickSandTinto wrapper classes<typename U> struct UnionWrapper { EActive tag; U u; /* ...*/ };.)