Overview
Chapter 7 introduces students to the C++ enum data type and the typedef statement.
Students will also explore the C++ namespace mechanism and its purpose. Finally,
students will learn how to manipulate strings with various C++ string functions.
Objectives
In this chapter, the student will:
• Learn how to create your own simple data type—called the enumeration type
• Explore how the assignment statement, and arithmetic and relational operators work
with enum types
• Learn how to use for loops with enum types
• Learn how to input data into an enum variable
• Learn how to output data stored in an enum variable
• Explore how to write functions to process enum types
• Learn how to declare variables when defining the enumeration type
• Become familiar with anonymous types
• Become familiar with the typedef statement
• Learn about the namespace mechanism
• Explore the string data type, and learn how to use string functions to manipulate
strings
Teaching Tips
Enumeration Type
1. Explain how the C++ enum type gives users the ability to create their own simple data
types.
2. Describe how an enum type is defined with a type name and potential values for that
type.
Discuss the limitations of the enum type in terms of its operations. You might
take this opportunity to briefly talk about object-oriented programming and
explain how classes overcome this limitation.