1 00:00:00,000 --> 00:00:02,400 (bright music) 2 00:00:02,400 --> 00:00:05,280 (keys clack) 3 00:00:05,280 --> 00:00:08,280 Frank: Welcome to this bonus section for the course. 4 00:00:08,280 --> 00:00:09,360 In this section, we'll learn 5 00:00:09,360 --> 00:00:12,480 about the basics of C++ enumerations 6 00:00:12,480 --> 00:00:15,993 also known as enumerated data types or enums. 7 00:00:17,370 --> 00:00:20,220 Please note that there are some concepts, constructs, 8 00:00:20,220 --> 00:00:22,260 and techniques that I will use in this section 9 00:00:22,260 --> 00:00:24,480 of the course that you may not have learned yet, 10 00:00:24,480 --> 00:00:27,300 depending on how much of the course you've completed. 11 00:00:27,300 --> 00:00:30,090 For example, I'll use the if, else statements, 12 00:00:30,090 --> 00:00:32,850 switch statements, the range based for loop, vectors, 13 00:00:32,850 --> 00:00:35,580 functions, and overloaded operators. 14 00:00:35,580 --> 00:00:37,500 All of these are covered in the course. 15 00:00:37,500 --> 00:00:39,660 If you haven't already completed those sections 16 00:00:39,660 --> 00:00:40,590 of the course, 17 00:00:40,590 --> 00:00:43,050 I strongly urge you to complete those sections 18 00:00:43,050 --> 00:00:44,760 before you do this one. 19 00:00:44,760 --> 00:00:45,780 For your reference, 20 00:00:45,780 --> 00:00:48,840 vectors are covered in sections seven and 20. 21 00:00:48,840 --> 00:00:51,090 Functions are covered in section 11. 22 00:00:51,090 --> 00:00:53,340 Strings are covered in section 10. 23 00:00:53,340 --> 00:00:56,280 Control structures such as the if, else switch 24 00:00:56,280 --> 00:01:00,000 and range based for loop are covered in section nine 25 00:01:00,000 --> 00:01:03,003 and operator overloading is covered in section 14. 26 00:01:05,580 --> 00:01:07,380 Enumerated types were first introduced 27 00:01:07,380 --> 00:01:10,710 in 1970 in the Pascal programming language. 28 00:01:10,710 --> 00:01:13,140 Since their creation, almost every other language 29 00:01:13,140 --> 00:01:17,130 has adopted enumerated data types of some form. 30 00:01:17,130 --> 00:01:18,840 Later, the C programming language 31 00:01:18,840 --> 00:01:20,820 introduced the enum keyword 32 00:01:20,820 --> 00:01:23,400 so in C++, enumerated types were inherited 33 00:01:23,400 --> 00:01:27,390 from C and extended in C++ 11 and forward. 34 00:01:27,390 --> 00:01:29,310 So what's an enumerated type? 35 00:01:29,310 --> 00:01:30,240 Well, in short, 36 00:01:30,240 --> 00:01:33,390 an enumerated type provides a useful way to store a set 37 00:01:33,390 --> 00:01:37,470 of named integral constants known as enumerators. 38 00:01:37,470 --> 00:01:39,146 In order to fully understand the enumerations, 39 00:01:39,146 --> 00:01:41,280 we need to take a closer look. 40 00:01:41,280 --> 00:01:43,236 First, we'll see what motivated the creation 41 00:01:43,236 --> 00:01:47,400 of enumerated data types and see how they became so popular. 42 00:01:47,400 --> 00:01:50,790 Next, we'll look at the syntax of a C++ enumeration 43 00:01:50,790 --> 00:01:52,530 and go through every part of it. 44 00:01:52,530 --> 00:01:53,700 We'll then see the difference 45 00:01:53,700 --> 00:01:56,280 between unscoped and scoped enumerations. 46 00:01:56,280 --> 00:02:00,600 Unscoped enumerations require no name qualification 47 00:02:00,600 --> 00:02:02,310 so they're visible throughout the scope 48 00:02:02,310 --> 00:02:04,470 in which the enumeration is defined. 49 00:02:04,470 --> 00:02:08,009 Scope enumerators do require a name qualification 50 00:02:08,009 --> 00:02:09,389 and so they can be accessed 51 00:02:09,389 --> 00:02:12,090 only using the scope resolution operator. 52 00:02:12,090 --> 00:02:14,220 Finally, we'll head over to the IDE 53 00:02:14,220 --> 00:02:17,610 and see some of the most common uses of enumerations. 54 00:02:17,610 --> 00:02:18,692 Before we get started, remember, 55 00:02:18,692 --> 00:02:22,500 I'm only covering the basics of C++ enumerations. 56 00:02:22,500 --> 00:02:23,333 Now let's head over 57 00:02:23,333 --> 00:02:25,950 to the next video to see what motivated the creation 58 00:02:25,950 --> 00:02:27,570 of enumerated data types 59 00:02:27,570 --> 00:02:29,713 and how they're used in C++.