1 00:00:00,630 --> 00:00:03,060 Plain old data classes. 2 00:00:03,060 --> 00:00:07,830 So classes are user defined types that contain data and functions. 3 00:00:07,830 --> 00:00:11,940 So and they are the heart and soul of C++. 4 00:00:11,940 --> 00:00:16,950 So the simplest kind of classes are plain all data classes P or DS. 5 00:00:16,950 --> 00:00:19,370 So bodies are simple containers. 6 00:00:19,380 --> 00:00:25,770 Think of them as a sort of heterogeneous array of elements and potentially different types. 7 00:00:25,770 --> 00:00:28,830 So each element is called a member. 8 00:00:28,830 --> 00:00:36,000 So every pod begins with the keyword struct here, followed by the pod name. 9 00:00:36,000 --> 00:00:38,940 So let's create a car struct here, for example. 10 00:00:39,450 --> 00:00:43,080 So next you list the members types and names. 11 00:00:43,080 --> 00:00:48,480 So for example, character, your name. 12 00:00:49,550 --> 00:00:59,240 Year or make year integer year integer tools or. 13 00:01:00,060 --> 00:01:01,160 It wheels. 14 00:01:02,600 --> 00:01:03,220 Here. 15 00:01:06,030 --> 00:01:07,740 And the boolean here. 16 00:01:07,740 --> 00:01:08,310 Let's assign. 17 00:01:08,310 --> 00:01:10,680 Boolean is running. 18 00:01:11,800 --> 00:01:12,210 Yes. 19 00:01:13,280 --> 00:01:13,870 Then. 20 00:01:14,930 --> 00:01:15,410 Here. 21 00:01:15,410 --> 00:01:25,970 As you can see here, a single car struct contains a character array called make and integer year integer 22 00:01:25,970 --> 00:01:29,660 wheels and bool is running boolean. 23 00:01:29,660 --> 00:01:34,760 So you declare that powered variables just like any other variables by type and name. 24 00:01:34,760 --> 00:01:41,150 So you can then access the members of the variable by using the dot operator. 25 00:01:41,150 --> 00:01:41,870 So. 26 00:01:41,870 --> 00:01:48,800 So first, let's firstly declare a car variable here. 27 00:01:51,490 --> 00:01:52,970 Car here. 28 00:01:55,390 --> 00:02:08,110 My Volks and my BMW here and then my BMW that is running with a sign is running to, for example. 29 00:02:08,170 --> 00:02:08,740 True. 30 00:02:09,020 --> 00:02:09,310 Yeah. 31 00:02:09,430 --> 00:02:13,150 My BMW is running, for example, through. 32 00:02:14,820 --> 00:02:26,670 Here and my BMW that make or sort of year is 2001 here this is all BMW and. 33 00:02:27,800 --> 00:02:28,160 Here. 34 00:02:28,160 --> 00:02:31,010 Finally, let's print the message. 35 00:02:31,130 --> 00:02:34,970 Your print is my or. 36 00:02:36,430 --> 00:02:38,500 My BMW. 37 00:02:38,540 --> 00:02:39,880 You're here. 38 00:02:42,320 --> 00:02:44,510 D and. 39 00:02:46,340 --> 00:02:48,740 My BMW that year. 40 00:02:49,640 --> 00:02:51,290 And let's print this. 41 00:02:53,280 --> 00:02:55,410 Here, as you can see here. 42 00:02:55,410 --> 00:03:08,100 Finally, you will print a message and extract a number or extract a year of my car using the this dot 43 00:03:08,100 --> 00:03:09,120 operator here. 44 00:03:09,120 --> 00:03:13,380 So pods have some useful low level features. 45 00:03:13,380 --> 00:03:20,640 So they are C compatible and you can employ machine instructions that are highly efficient to copy or 46 00:03:20,640 --> 00:03:24,420 move them so and they can be efficiently represented in the memory. 47 00:03:24,480 --> 00:03:31,500 So a C++ guarantee is that members feel sequential in memory, although some implementations require 48 00:03:31,500 --> 00:03:37,410 members to build align the long word binary, so which depends on the CP register length. 49 00:03:37,410 --> 00:03:47,160 So as a general rule, you should order members from a lattice to a small list within P or the definitions.