Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,270 --> 00:00:01,600
What is going on, guys?
2
00:00:01,740 --> 00:00:08,970
In this video, we are going to talk about how we can create destructs templates in our programming
3
00:00:08,970 --> 00:00:10,380
language, so.
4
00:00:11,320 --> 00:00:12,240
Here we go.
5
00:00:12,450 --> 00:00:21,450
And the first thing that I want to say is that our computer, lets say and our program knows nothing
6
00:00:21,450 --> 00:00:24,940
about this Trachte we are planning to use.
7
00:00:24,990 --> 00:00:32,140
OK, so we maybe have some idea of some structure that we want to use for the needs of our program.
8
00:00:32,160 --> 00:00:39,990
And if you want to create this new variable of some Newstrike type, then what we should first of all
9
00:00:39,990 --> 00:00:49,740
specify is exactly how the structure should look like before we create a variable of this given structure.
10
00:00:49,920 --> 00:00:58,380
So basically, what we have to do is we have to define the structure of the new struct, simple as that.
11
00:00:58,800 --> 00:01:05,530
And by defining this new struct template, we are simply creating some new box template, OK, just
12
00:01:05,530 --> 00:01:10,830
the template that we can use to create variables of this particular type.
13
00:01:11,190 --> 00:01:18,180
And I'm repeating myself because that's very important to understand the difference between using and
14
00:01:18,180 --> 00:01:27,780
creating the structure template and creating variables and creating these new boxes out of this particular
15
00:01:27,780 --> 00:01:28,470
template.
16
00:01:29,100 --> 00:01:36,350
So you may recall that we've been using simple variables or a standard variables, just like integer
17
00:01:36,360 --> 00:01:39,050
double float char and so on.
18
00:01:39,210 --> 00:01:47,230
And now we are going to use a new way of creating a box template and then creating box variables.
19
00:01:47,670 --> 00:01:53,730
So basically, we already have multiple ready to use types of variables, just like we've seen before.
20
00:01:54,000 --> 00:01:55,020
And that's cool.
21
00:01:55,260 --> 00:01:57,770
And now we want to create our new structure.
22
00:01:58,290 --> 00:02:06,980
So probably we can see that the first step to do so would be, let's say, to create the new structure
23
00:02:07,380 --> 00:02:11,070
so that we are going to use the word struct.
24
00:02:11,100 --> 00:02:13,490
OK, let me use my laser here.
25
00:02:13,500 --> 00:02:14,760
So here you go.
26
00:02:14,760 --> 00:02:16,440
Here you can see struct.
27
00:02:16,680 --> 00:02:23,700
And this specifies this whole structure template specifies not the variable that we are going to use,
28
00:02:23,700 --> 00:02:25,860
but rather adjust the struct template.
29
00:02:26,130 --> 00:02:33,660
So the keyword struct is a building keyword specifying that we are about to use something related to
30
00:02:33,660 --> 00:02:35,160
struct makes sense.
31
00:02:35,160 --> 00:02:35,510
Right.
32
00:02:36,030 --> 00:02:46,140
And there then you specify the structure or name avert it basically generally be like a very descriptive
33
00:02:46,140 --> 00:02:49,620
name for the structure that you are about to create.
34
00:02:50,940 --> 00:02:56,040
When we have these nice curly brackets, the curly brackets actually play.
35
00:02:56,040 --> 00:03:00,400
Here are an important role in defining the structures nature.
36
00:03:00,580 --> 00:03:10,440
OK, the curly brackets simply start a block, OK, a block which describes the fields that we are going
37
00:03:10,620 --> 00:03:13,470
to use as part of the structure.
38
00:03:13,500 --> 00:03:21,540
OK, so you specify the war the keyword struct, then you specify the structure and name using the curly
39
00:03:21,540 --> 00:03:22,140
brackets.
40
00:03:22,140 --> 00:03:31,280
You specify what fields are going to be part of this new structure and these times maybe just like regular.
41
00:03:31,650 --> 00:03:37,530
And if we want to take a closer look, know like to take all of this structure into, look how it will
42
00:03:37,530 --> 00:03:38,690
look behind the scenes.
43
00:03:38,970 --> 00:03:41,130
So basically it will be something like that.
44
00:03:41,230 --> 00:03:47,910
Here are the smaller the smaller boxes, OK, which are just these fields, OK, under the structure.
45
00:03:48,150 --> 00:03:55,380
And we simply take a couple of smaller boxes, OK, smaller boxes and we put them, all of them inside
46
00:03:55,380 --> 00:04:01,840
of this new structure template that we've just created under this structure and name.
47
00:04:02,160 --> 00:04:03,080
No worries, guys.
48
00:04:03,330 --> 00:04:10,020
Once you will understand this concept and you will see a couple of examples, everything will become
49
00:04:10,020 --> 00:04:11,820
much more clear to you.
50
00:04:11,820 --> 00:04:13,020
So no worries.
51
00:04:13,020 --> 00:04:17,190
Just try to keep up the pace and let's proceed.
52
00:04:17,340 --> 00:04:21,020
Let's proceed to our couple of examples.
53
00:04:21,030 --> 00:04:28,200
OK, so the first example that I want to show you guys is the example of creating a date structure.
54
00:04:28,770 --> 00:04:37,050
So simply saying we want to have some new structure that will represent a date in a date consists of,
55
00:04:37,050 --> 00:04:40,080
first of all, day, month and year.
56
00:04:40,110 --> 00:04:47,490
OK, so instead of specifying like date one in day one indeed, two in a day, three in four months,
57
00:04:47,490 --> 00:04:56,520
one month two and so on, we want all of the fields related to a given date be located under one structure.
58
00:04:56,850 --> 00:04:58,710
So we use struct.
59
00:04:58,860 --> 00:04:59,700
We said that.
60
00:04:59,990 --> 00:05:07,010
Is the key word that we are going to use when we use and specify the structure template name in this
61
00:05:07,010 --> 00:05:08,720
case, I want to create a date.
62
00:05:08,990 --> 00:05:11,390
So date is pretty good in here.
63
00:05:11,390 --> 00:05:18,530
We have three fields that are under this structure, so into day and month and into year.
64
00:05:18,920 --> 00:05:25,940
So that's how we create our vele our struct template of date.
65
00:05:26,280 --> 00:05:32,600
OK, and if we want to take a look at a couple of other examples, let's say we wanted to create, I
66
00:05:32,600 --> 00:05:34,040
don't know, like a point.
67
00:05:34,040 --> 00:05:41,360
OK, if you're a little bit into math so you know that you have a point and which consists of X and
68
00:05:41,360 --> 00:05:42,680
Y coordinates.
69
00:05:43,460 --> 00:05:50,840
So you know that a point is just can be represented by an X and Y values.
70
00:05:51,020 --> 00:05:58,220
And you specify indexing Y, you also could have used float X, float Y, double double Y, OK, if
71
00:05:58,430 --> 00:06:00,520
you want a floating point numbers.
72
00:06:01,010 --> 00:06:02,340
So that's also OK.
73
00:06:02,390 --> 00:06:06,550
That's how we create a structure template of point.
74
00:06:06,560 --> 00:06:08,470
So I think everything is clear.
75
00:06:08,480 --> 00:06:10,270
So far nothing complicated.
76
00:06:10,280 --> 00:06:10,580
Right.
77
00:06:10,580 --> 00:06:15,780
We're moving on together to understanding these concepts once and for all.
78
00:06:15,830 --> 00:06:16,780
OK, guys.
79
00:06:16,820 --> 00:06:23,420
So the last example here is, for example, you want to create and to use this part of your program
80
00:06:23,420 --> 00:06:25,310
as awesome future a developer.
81
00:06:25,310 --> 00:06:25,660
Right.
82
00:06:25,700 --> 00:06:28,450
You also want to use some address.
83
00:06:28,460 --> 00:06:37,730
OK, so you want to have a structure that represents an address of some employee, of some person or
84
00:06:37,730 --> 00:06:44,600
I don't know if you're making some application that uses addresses, that may be a good way, maybe
85
00:06:44,600 --> 00:06:47,420
for some applications to store it this way.
86
00:06:47,420 --> 00:06:55,340
So instead of using like char, state of bio, char, city of Beeld, Charge, Charra, state of George
87
00:06:55,520 --> 00:07:02,000
and so on, like for everybody, we are going to create a structure using this structure template to
88
00:07:02,000 --> 00:07:08,370
represent the exact address of any given person that we want to have in our application.
89
00:07:08,660 --> 00:07:14,180
So under this template, we will have the state will give it like 20 characters.
90
00:07:14,180 --> 00:07:20,780
Let's say, for example, we will have this city of ten characters, the street, which is represented
91
00:07:20,780 --> 00:07:28,030
by 15 characters and also will have the number of the street that will be represented as an integer.
92
00:07:28,040 --> 00:07:36,140
OK, so you see, we make here a lot of combinations between different variables and different data
93
00:07:36,140 --> 00:07:41,450
types and putting them all under a new structure template that we created.
94
00:07:41,540 --> 00:07:48,320
And we specify the structure template name here after these structures, throughout the address created
95
00:07:48,320 --> 00:07:54,440
a new struct address, created a new struct point, created a new struct date and one thing.
96
00:07:54,440 --> 00:08:01,460
And it's very important to understand, guys, we just created this video in this video at this stage,
97
00:08:01,460 --> 00:08:03,860
we just created the structure template.
98
00:08:04,100 --> 00:08:12,890
In the next videos, we are going to see how we can create variables, actual variables that are represented
99
00:08:12,890 --> 00:08:20,420
in the memory of our computer and of these particular types, just like we created in today.
100
00:08:20,490 --> 00:08:21,730
OK, whenever you will.
101
00:08:21,860 --> 00:08:24,710
We're using different applications.
102
00:08:24,710 --> 00:08:31,650
You wrote in today and in this step that you wrote in day, you created a new variable date.
103
00:08:31,700 --> 00:08:40,220
So what we are going to do is to create a new date that will consist of these fields and new variable
104
00:08:40,220 --> 00:08:48,170
of type struct date that will have as each bar in today, each month and each year.
10738
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.