Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: redeclaration of enumerators? Date: Wed, 29 Sep 2021 18:25:40 -0700 Organization: None to speak of Lines: 20 Message-ID: <87tui2j1m3.fsf@nosuchdomain.example.com> References: <8735pojrc3.fsf@nosuchdomain.example.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="4b075a85c80fa8b78011f466bfabf6da"; logging-data="15654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ayfLJijtBAORy+PTfLmGB" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:2xXhHd/fdWYdmgDerysdYVe2Tb8= sha1:2+u79OTsT1pjB9DY16CpXabLUjw= Xref: csiph.com comp.lang.c:162873 David Brown writes: [...] > With strong enumerations, you shouldn't even be thinking of them as > having an integer value - it doesn't make sense to compare the "value" > of a "colours" enumeration element with one from a "lights" enumeration. > That is a large part of the point of having better enumeration types > than were available in C. C++ scoped enumeration types do have well-defined integer representations. You can even specify them in the declaration: enum class foo { zero = 0, one = 1 }; There's no implicit conversion from foo to int, but you can use a cast; for example (int)foo::zero == 0. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */