POV-Ray : Newsgroups : povray.off-topic : Lots of statistics : Re: C# WTF list Server Time
29 Jul 2024 20:21:20 EDT (-0400)
  Re: C# WTF list  
From: Warp
Date: 15 Aug 2012 08:20:44
Message: <502b941c@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Trying to assing an int to an enum variable, I get a "Cannot implicitly 
> convert [...]" error for any integer value other than 0. (Don't ask me 
> why they did allow it for 0 though.)

If it works like C++ enums, then enumerated constants will implicitly cast
to integrals, though (and integrals can be cast explicitly to enums).

While this is useful oftentimes (there are many, many situations where
an enumerated list of names is much handier than writing integral constants),
there are othertimes where strongly-typed enums would be more desirable.

C++11 added strongly-typed enums to the language (in addition to the existing
weakly-typed ones). If an enumerated type is not intended to be used as
an integral, then you can now say so. (You can also specify its underlying
type if you want.)

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.