Hi,
What is the main difference between using in a class a static enum or writting this enum in a separate class ?
Both can be accesed from outside.
thanks
Printable View
Hi,
What is the main difference between using in a class a static enum or writting this enum in a separate class ?
Both can be accesed from outside.
thanks
You have direct access to the (private) static members of the outer class (when using a inner static enum)
Hi,
That one i know, but the question is more, when do i use an enum class and when a static enum.
what are the (dis)avantages of the one vs the other ?
thanks
Neatness mainly.
And logical grouping.
If the enum is small and associated purely with what is going on in the outer class then maybe keep it in there, but if it's for use outside the class, and/or has a load of its own code then I'd consider sticking it in its own file. Unless (as said above) you need access to some of the data in the outer class.