On Wed, 19 Jun 2024 09:38:24 -0300, Thiago Adams wrote:
On 19/06/2024 04:24, Lawrence D'Oliveiro wrote:
On Tue, 18 Jun 2024 08:09:13 -0300, Thiago Adams wrote:
This creates a kind of encapsulation.
Why not just use “int” or “unsigned int”? Why does the caller even need
to
know it’s an enum?
The advantage will be the type check at the implementation file (some compiler have extra type check for enuns) ...
Obviously this is not a language requirement, so I’m not sure of the
point. E.g. GCC compiles this rather flagrant example without complaint:
enum colours {red, green, blue};
enum colours colour = 9;
I even tried “-Wall -Wpedantic”, to no effect.
... and clarity about the possible values accepted.
As a documentation aid? Again, that’s implementation-specific, nothing to
do with the caller-visible interface.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)