The Java code by Oracle tends to use constant integer identifiers where the equivalent would be an enum in C++. The nice thing about using the CIIs that you can easily add more in the base class or a derived class and not break the code (too badly…). My question is: Is there a way to achieve this using an enum in C++ or would I have to stick to constants?
The Java code by Oracle tends to use constant integer identifiers where the equivalent
Share
You can do that in Java because it’s bytecodes are interpreted (or, more likely recently “Just-in-Time” compiled) : You have separate pieces and they are put together at run-time.
C++ is fully compiled to native code. Any change will require a ful compile. If a full recompile is acceptable, then adding a new item to a enum is possible, and even less likely to break code than adding CIIs.