I was looking around in this website structure tutorial and i noticed a similarity between structures and classes, that similarity lead me to this conclusion.
When ever you create a structure all that is required of it is a name to be listed by. And that given name holds information on the allocation of the variable/const that you implement within your structure. A similarity between classes and structure is that they both require the use of objects to be able to access them. Also in order to access the content within structure and classes one must use the object initialized with the combination of DOT 's. Regardless a difference between the two is that structure cannot be implemented from a second hand header file, and unlike structure , classes require classification between public and private. This is based on my understanding. The purpose of this post is to receive corrections on my theory/ way of thinking and hear for other theories and explanations.
The similarity between struct and class is that they're identically. The only difference is the default behavior when it comes to private or public.
struct is public by default while class is private
Personally, I use a struct when there's only public variables and one or more constructors. I use a class for anything that has private members or methods.
I don't like structs to have methods, I don't think it makes sense. I only write a constructor because C++ doesn't allow struct coords my_coords = { 0, 1 }; so I have to do coords my_coords(0, 1); instead.
It's common to find structs representing POD (Plain Old Data) types, or to represent something that isn't an object in the real world. classes on the other hand, are used to represent something that would be a physical object in the real world, such as a car.
I guess the answer to your "why" is "why not". Union is still there because it's still useful (you probably know already but on the off-chance you don't, union's purpose is to store multiple variables in the same location in memory, which has various uses.).
Then rax.value is the value of RAX, rax.low.value is the value of EAX, rax.low.low.value is the value of AX, rax.low.low.s.high is the value of AH and rax.low.low.s.low is the value of AL.
That's poor use of the union. That's not guaranteed by the standard to be failsafe and is probably compiler specific (for the x86 emulator, the typing use is very common).