Lecture C++ programming: from problem analysis to program design - Chapter 8: User-defined simple data types, namespaces, and the string type

In this chapter, you will: Learn how to create and manipulate your own simple data type—called the enumeration type; become familiar with the typedef statement; learn about the namespace mechanism; explore the string data type, and learn how to use the various string functions to manipulate strings. | C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 8: User-Defined Simple Data Types, Namespaces, and the string Type C++ Programming: From Problem Analysis to Program Design, Fourth Edition Objectives In this chapter, you will: Learn how to create and manipulate your own simple data type—called the enumeration type Become familiar with the typedef statement Learn about the namespace mechanism Explore the string data type, and learn how to use the various string functions to manipulate strings C++ Programming: From Problem Analysis to Program Design, Fourth Edition Enumeration Type Data type: a set of values together with a set of operations on those values To define a new simple data type, called enumeration type, we need three things: A name for the data type A set of values for the data type A set of operations on the values C++ Programming: From Problem Analysis to Program Design, Fourth Edition Enumeration Type (continued) A new simple | C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 8: User-Defined Simple Data Types, Namespaces, and the string Type C++ Programming: From Problem Analysis to Program Design, Fourth Edition Objectives In this chapter, you will: Learn how to create and manipulate your own simple data type—called the enumeration type Become familiar with the typedef statement Learn about the namespace mechanism Explore the string data type, and learn how to use the various string functions to manipulate strings C++ Programming: From Problem Analysis to Program Design, Fourth Edition Enumeration Type Data type: a set of values together with a set of operations on those values To define a new simple data type, called enumeration type, we need three things: A name for the data type A set of values for the data type A set of operations on the values C++ Programming: From Problem Analysis to Program Design, Fourth Edition Enumeration Type (continued) A new simple data type can be defined by specifying its name and the values, but not the operations The values must be identifiers Syntax: value1, value2, are identifiers called enumerators value1 Enumeration Type (continued) Enumeration type is an ordered set of values If a value has been used in one enumeration type it can’t be used by another in same block The same rules apply to enumeration types declared outside of any blocks C++ Programming: From Problem Analysis to Program Design, Fourth Edition Enumeration Type (continued) C++ Programming: From Problem Analysis to Program Design, Fourth Edition Declaring Variables Syntax: For example, given the following definition: we can declare the following variables: C++ Programming: From Problem Analysis to Program Design, Fourth Edition Assignment The statement: popularSport = FOOTBALL; stores FOOTBALL into popularSport The statement: .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
134    185    6    01-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.