I think not .
union has nothing to do with the orientation of the object .
C ++ never says that it intends to support only OO. C ++ supports a multiple paradigm from the beginning (meanwhile: procedural, functional, generative, object-oriented)
C ++ 11 supports โ unlimited joins, โ but I don't see any use in terms of OO
Depending on the author, the orientation of the object requires the following problems:
- identity
- inheritance / generalization
- polymorphy
- Encapsulation
In the case of union, the first problem is valid. The association can be identified (for example, at its address)
For unions there is no concept of inheritance .
It can be argued that the data are polymorphic in the union, but this interpretation is far from what the oo considers to be polymorphic. A union cannot have a virtual function that would be almost useless without inheritance. And that will break the memory layout.
In a combination of encapsulation . However, due to limitations, I do not expect useful applications for this case. If I were grateful for the link
With this feature set, I would consider the "abstract data type" (ADA) as the right term.
source share