Re: Prohibit enum <-> int mixup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 29 January 2011 20:48, Enrico Weigelt wrote:
>
> I'm using C++. It already warns me about a few things, eg. missing
> case's in switch statements. But it still accepts assigning
> enum to int and vice versa.

No it doesn't, C++ allows enums to be assigned to ints but not the
other way around.

enum e { val };
e var = 0;

e.cc:2: error: invalid conversion from ‘int’ to ‘e’



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux