C++0x, scoped enums

Introduction and good usage patterns for scoped enumerations

From the developerWorks archives

Wael Y. Yehia

Date archived: April 18, 2019 | First published: September 18, 2012

This articles introduces the new scoped enums feature from the new C++ standard, C++0x. Scoped enums are meant to help you write more portable and more expressive code. For instance, scoped enums can have an explicit underlying type that improves portability, can be forward declared, and do not undergo any implicit conversions. That enhances type safety. The previous enum behavior still exists and is now referred to as unscoped enum. Unscoped enums are able to inherit some of the functionality of the scoped enums, such as explicit underlying type and forward declaration. This article describes all aspects of scoped enums and provides examples, along with good usage patterns that you might find useful.

This content is no longer being updated or maintained. The full article is provided "as is" in a PDF file. Given the rapid evolution of technology, some content, steps, or illustrations may have changed.



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=835304
ArticleTitle=C++0x, scoped enums
publish-date=09182012