Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,840 --> 00:00:10,230
OK, so now let me show you how we can basically write a couple of functions to make some relational
2
00:00:10,260 --> 00:00:11,220
operations.
3
00:00:12,000 --> 00:00:14,540
And we will start with something very, very nice.
4
00:00:14,550 --> 00:00:20,970
We will start with writing a function that should compare between two given point.
5
00:00:21,420 --> 00:00:24,450
OK, so let's say we will compare.
6
00:00:25,710 --> 00:00:27,750
Let's use and equal points.
7
00:00:27,960 --> 00:00:35,730
Equal points in these functions should receive just two points point B one and point B two.
8
00:00:36,420 --> 00:00:44,880
And basically, all this function is going to do is to compare between all of the fields in this point
9
00:00:45,060 --> 00:00:47,010
in point B one and point B two.
10
00:00:47,820 --> 00:00:52,380
And we are going to say that e f p one dot x.
11
00:00:52,740 --> 00:00:53,170
OK.
12
00:00:53,190 --> 00:00:56,290
Very important to not use if b one equals two P2.
13
00:00:56,910 --> 00:00:57,720
We talked about it.
14
00:00:57,840 --> 00:01:00,630
That simply wont work, at least not for now.
15
00:01:01,770 --> 00:01:16,470
So we will say that if P1.6 equals two p one dot b two that X and do p one dot y equals to B to that
16
00:01:16,470 --> 00:01:16,890
y.
17
00:01:17,220 --> 00:01:21,390
OK, then if that happens, then we can return.
18
00:01:21,390 --> 00:01:25,980
Let's say they are equal, we will return one else.
19
00:01:26,130 --> 00:01:27,630
We will return zero.
20
00:01:27,720 --> 00:01:29,190
The LS is not mandatory here.
21
00:01:29,190 --> 00:01:32,160
We can't simply write the return zero, but never mind.
22
00:01:32,400 --> 00:01:37,980
So what we've done here is we created a function to compare between two given points.
23
00:01:38,580 --> 00:01:45,050
OK, so we say equal point is a function getting two points and each compares between these two points
24
00:01:45,060 --> 00:01:53,400
field by field and returning one if they are equal and zero if not, so how these function will be called,
25
00:01:53,550 --> 00:01:54,410
you know, let's see.
26
00:01:54,420 --> 00:01:55,040
And main.
27
00:01:55,320 --> 00:01:56,970
And we have here an example.
28
00:01:56,970 --> 00:01:59,300
So let's create an endpoint point.
29
00:01:59,470 --> 00:02:07,440
One will be equal to one and two and we will have to, which would be equal to let's see.
30
00:02:08,630 --> 00:02:10,070
Four and one.
31
00:02:10,880 --> 00:02:12,080
I don't know something like that.
32
00:02:12,710 --> 00:02:20,690
So we want to know if both of these points are equal, so one way to do it is basically to say, Ah,
33
00:02:20,750 --> 00:02:21,200
if?
34
00:02:23,230 --> 00:02:28,450
If right, and we can ask a simple question, we can ask if equal point.
35
00:02:29,410 --> 00:02:36,370
Equal points, let's say equal points more correctly, if equal points on these two points point one
36
00:02:36,370 --> 00:02:41,170
and point to if this result does not equal to zero.
37
00:02:42,400 --> 00:02:46,370
Then it means that they are equal, so we know here.
38
00:02:46,690 --> 00:02:51,880
Code related to the fact that they were equal.
39
00:02:53,430 --> 00:02:56,840
The points were were are equal.
40
00:02:57,740 --> 00:02:59,570
OK, so that's what we do.
41
00:02:59,750 --> 00:03:05,690
We simply compare between these two points by using an equal points function.
42
00:03:06,380 --> 00:03:13,700
Any of these function returns a value that is not zero like in this case, we can say simply that.
43
00:03:15,180 --> 00:03:16,320
They are equal.
44
00:03:16,860 --> 00:03:17,340
OK?
45
00:03:17,820 --> 00:03:18,510
Is it clear?
46
00:03:19,140 --> 00:03:21,990
So we couldn't use it the equality sign.
47
00:03:22,450 --> 00:03:24,910
Like if b one equals equals to two?
48
00:03:25,530 --> 00:03:28,350
But we can use it this way by using equal points.
49
00:03:29,550 --> 00:03:30,090
OK.
50
00:03:30,300 --> 00:03:37,380
So basically here you will write down any code associated with the result of this condition being true
51
00:03:37,620 --> 00:03:40,890
or if it's false, related to the yellow section.
52
00:03:41,700 --> 00:03:42,060
OK.
53
00:03:43,080 --> 00:03:50,100
Another example if we want to write down a function that basically compares between two points and says
54
00:03:50,340 --> 00:03:53,910
not equal points, not equal points.
55
00:03:54,180 --> 00:04:00,060
OK, so this was kind of associated with this relational operator.
56
00:04:00,180 --> 00:04:00,510
Right?
57
00:04:01,320 --> 00:04:03,390
And this one will be associated with.
58
00:04:05,150 --> 00:04:15,470
This relational operator not equal, so it will also get point B one in point P2, but all he's going
59
00:04:15,470 --> 00:04:17,570
to do is something else.
60
00:04:17,600 --> 00:04:18,800
What is it going to do?
61
00:04:19,700 --> 00:04:22,790
It's going to compare between them a little bit differently.
62
00:04:23,060 --> 00:04:29,450
If P1.6 does not equal to be 2.6 or OK, right, we can copy that.
63
00:04:29,750 --> 00:04:32,840
We can say you could be one that does not equal to P2 Reddick's.
64
00:04:33,260 --> 00:04:39,170
Or at least be wonder why does not equal to be two that way, then we can return one.
65
00:04:40,580 --> 00:04:42,440
Otherwise we can return zero.
66
00:04:43,560 --> 00:04:45,120
OK, very, very simple.
67
00:04:45,690 --> 00:04:51,300
So we created two functions kind of associated with the equality and not equality.
68
00:04:51,510 --> 00:04:53,580
Lodge relational operators.
69
00:04:55,440 --> 00:05:02,040
Of course, we could have used the implementation of this function, not equal points, by calling the
70
00:05:02,040 --> 00:05:07,680
equal points and basically stating the opposite result OK, return, not equal points.
71
00:05:07,800 --> 00:05:11,280
Well, I did the the most trivial way.
72
00:05:11,700 --> 00:05:15,160
OK, so that's one way to use the relational operators.
73
00:05:15,180 --> 00:05:15,570
OK.
74
00:05:15,870 --> 00:05:21,990
So in C, we cannot use operator overloading, which is the whole topic on itself.
75
00:05:22,380 --> 00:05:32,400
But in C++, the basically the arm operator overloading section is one of its biggest features.
76
00:05:32,460 --> 00:05:36,090
OK, so that's something that I recommend you to also learn.
77
00:05:36,120 --> 00:05:37,740
OK, here we are in this way.
78
00:05:38,040 --> 00:05:39,870
Here we will learn it this way.
79
00:05:40,020 --> 00:05:44,160
OK, so that's just two examples to the using the points.
80
00:05:44,460 --> 00:05:51,630
And also, let's use, I don't know some additional example on like how we can compare between employees.
81
00:05:52,440 --> 00:05:53,680
So let's create something.
82
00:05:53,700 --> 00:05:56,880
OK, let's say ain't.
83
00:05:57,840 --> 00:06:06,300
Equal by age, and we will receive two employees, we will receive employee e one and we will receive
84
00:06:06,300 --> 00:06:08,430
employee employer.
85
00:06:09,680 --> 00:06:17,300
E e two, so there are going to be two employees and we are going to compare them by age, so we are
86
00:06:17,300 --> 00:06:20,420
going to ask a simple question if you want what age?
87
00:06:21,470 --> 00:06:23,600
Right, if E one dot h.
88
00:06:24,640 --> 00:06:31,900
And we can make these function even more unique, if it's equal to equal to that age, then we can return
89
00:06:31,900 --> 00:06:32,350
zero.
90
00:06:34,340 --> 00:06:34,700
Right.
91
00:06:35,840 --> 00:06:41,690
But if, OK, we can use the else, it's not mandatory, but just for simplicity, let's use it.
92
00:06:42,110 --> 00:06:47,090
But if you want that age is less, then e to that age.
93
00:06:48,010 --> 00:06:52,450
Then we can decide on some, I don't know, signature for our own return minus one.
94
00:06:54,800 --> 00:07:00,170
And else, if that's not the case, this is referred to e to.
95
00:07:01,530 --> 00:07:06,480
Don't age or wonder age greater than E to that age.
96
00:07:07,300 --> 00:07:10,140
OK, that's so then we will return one.
97
00:07:10,140 --> 00:07:10,380
So.
98
00:07:12,120 --> 00:07:14,820
We have written some function.
99
00:07:14,850 --> 00:07:18,160
OK, maybe instead of equal, we will use compare by age.
100
00:07:18,870 --> 00:07:27,060
And this function is responsible for comparing to employees variables two variables of an employee type
101
00:07:27,060 --> 00:07:27,870
by age.
102
00:07:28,710 --> 00:07:37,110
So this function is of the following structure If both of the employees have the same age, then the
103
00:07:37,110 --> 00:07:38,930
function is going to return zero.
104
00:07:40,410 --> 00:07:47,520
If the first stage, the first employee is younger than the second one, then we are going to return
105
00:07:47,520 --> 00:07:47,850
one.
106
00:07:48,300 --> 00:07:55,090
And if the second employee is younger than the first one, we are going to return one.
107
00:07:55,110 --> 00:07:57,510
OK, so minus one one in zero.
108
00:07:57,870 --> 00:08:08,430
That's just something that we've created to kind of mimic the relational operations between two elements
109
00:08:08,430 --> 00:08:10,410
two variables of an employee type.
110
00:08:11,690 --> 00:08:12,090
OK.
111
00:08:12,110 --> 00:08:19,460
By comparing the age, we could also do pretty much the same just by comparing their IDs, right?
112
00:08:19,790 --> 00:08:21,670
We can compare by I.D..
113
00:08:23,840 --> 00:08:26,990
We can compare by aid, so if I did.
114
00:08:27,920 --> 00:08:32,450
And that's the case and the same here and the same here, right?
115
00:08:33,260 --> 00:08:35,210
Pretty much so.
116
00:08:35,210 --> 00:08:41,660
Now in the main function, we will be basically able to create variables of an employee type.
117
00:08:42,350 --> 00:08:46,680
And then if we need it, we can call these functions compare by idea.
118
00:08:46,730 --> 00:08:52,280
We can call these function, compare by age and basically provided with two employees.
119
00:08:52,550 --> 00:08:56,660
And these functions are going to compare them by one of these fields.
120
00:08:56,870 --> 00:08:59,870
We can also use it for comparing by name, right?
121
00:08:59,900 --> 00:09:01,490
There is also an option to do that.
122
00:09:02,300 --> 00:09:07,190
But I think you've got the idea of how we can use it to our advantage.
123
00:09:08,120 --> 00:09:11,570
So we hope that everything regarding this matter is clear to you.
124
00:09:12,080 --> 00:09:14,900
And yeah, thank you guys for watching.
125
00:09:15,320 --> 00:09:16,160
Let's proceed.
11223
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.