All language subtitles for 13. Logical Operators 1 - Can we use Relational Operators on Structs by default

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,730 --> 00:00:07,840 What is going on, ladies and gentlemen, and welcome to this very, very important video in our programming 2 00:00:07,840 --> 00:00:11,080 course as well as in your programming career. 3 00:00:11,800 --> 00:00:17,350 So in this video, we are going to talk about a couple of things, but mostly we are going to talk about 4 00:00:17,350 --> 00:00:25,750 how we can use relational operators such as smaller, bigger or smaller or equal, bigger or or equal, 5 00:00:26,380 --> 00:00:31,030 not equal or totally equal using structs. 6 00:00:31,240 --> 00:00:38,410 OK, so we know how to use relational operators with just some standard variable standard data types 7 00:00:38,740 --> 00:00:41,410 such as integers, floats, doubles and so on. 8 00:00:41,950 --> 00:00:48,730 But now what we are going to do is to take a look at how and if we can take advantage of these relational 9 00:00:48,730 --> 00:00:54,670 operators and use them between different variables of certain struct. 10 00:00:55,300 --> 00:00:55,690 OK. 11 00:00:55,960 --> 00:01:02,890 And we will see that it's not so trivial, and it's not kind of very, very easy and intuitive, but 12 00:01:03,250 --> 00:01:10,360 we will need to think of a way to find out how we can implement what we are looking for. 13 00:01:10,660 --> 00:01:18,400 OK, so I think that the best way to start these explanation is just by giving you these little nice 14 00:01:18,400 --> 00:01:20,020 examples that you can see on the screen. 15 00:01:20,740 --> 00:01:26,890 So we are going to take a look at two different structs, and hopefully by the end of this video, everything 16 00:01:26,890 --> 00:01:28,240 will be clearer to you. 17 00:01:28,270 --> 00:01:31,540 OK, so that's something we will refer right away. 18 00:01:32,200 --> 00:01:36,400 So let us, first of all, start with this typedef struct point. 19 00:01:36,670 --> 00:01:38,440 So we have the structure of point. 20 00:01:38,710 --> 00:01:39,730 Nothing can new so far. 21 00:01:41,280 --> 00:01:46,350 And we are going to take a look at how we can create two variables of these struct. 22 00:01:46,680 --> 00:01:47,100 OK? 23 00:01:47,130 --> 00:01:49,680 The first variable will be B one. 24 00:01:50,760 --> 00:01:57,120 And the second variable will be to one of them is going to be with the values of three and five in the 25 00:01:57,120 --> 00:02:00,810 second one with the values of two and six for X and Y. 26 00:02:02,060 --> 00:02:03,110 Respectively. 27 00:02:03,140 --> 00:02:03,650 OK. 28 00:02:04,160 --> 00:02:11,960 So we create two objects initialize them, and then what I want to ask you is a simple question if we 29 00:02:11,960 --> 00:02:15,120 can or not compare between them. 30 00:02:15,140 --> 00:02:21,560 I mean, I want to find out and write these kind of logical tests. 31 00:02:21,890 --> 00:02:26,330 I want to see if P1 is greater than P2. 32 00:02:27,200 --> 00:02:30,140 And that's something that is very important to understand. 33 00:02:30,800 --> 00:02:34,280 We compare now not just between two integers. 34 00:02:34,310 --> 00:02:41,300 OK, so we know how to find which which of doing the jurors is greater, which is the smaller and so 35 00:02:41,300 --> 00:02:41,540 on. 36 00:02:41,780 --> 00:02:44,750 We also know how to do it for floats and doubles and so on. 37 00:02:46,220 --> 00:02:51,680 Now we tried to compare between two variables of a user defined type. 38 00:02:52,100 --> 00:02:54,140 For example, point that we've just created. 39 00:02:55,100 --> 00:03:02,150 So the question is, how should you compare between and B2, let's say you want to find out if B1 is 40 00:03:02,150 --> 00:03:09,530 greater than B2, then to run some code lalala and then to print that point one is greater than point 41 00:03:09,530 --> 00:03:09,860 two. 42 00:03:09,950 --> 00:03:10,220 OK. 43 00:03:10,850 --> 00:03:17,990 Basically, associate some code with with the answer to these condition. 44 00:03:18,920 --> 00:03:25,910 But the question is how can you even think about comparing B1 B2 to variables of a point type? 45 00:03:26,390 --> 00:03:32,180 I mean, what fields will be used to decide the result of these condition? 46 00:03:32,720 --> 00:03:34,700 What fields would you like to test? 47 00:03:34,700 --> 00:03:42,590 Would we like to know only if B1 is greater than B2 just by using its ICS field, just by comparing 48 00:03:42,590 --> 00:03:43,880 the ICS data member? 49 00:03:44,240 --> 00:03:50,540 Or maybe would like to know if it's decided by one by five by five by white. 50 00:03:51,800 --> 00:03:58,850 So, I mean, if we take a look at P1 and P2 and we ask which one of them is greater than the other 51 00:03:59,480 --> 00:04:02,690 in correspondence, do the X value. 52 00:04:02,690 --> 00:04:06,080 So we can say definitely that P1 is greater, right? 53 00:04:06,080 --> 00:04:10,280 Because P1 died three and P2 X is two. 54 00:04:10,880 --> 00:04:18,590 So we can say that in correspondence do the X value P1 will be considered greater. 55 00:04:19,490 --> 00:04:28,550 But if we will take a look by the Y value of these two variables, we can see that P2 has a y value 56 00:04:28,550 --> 00:04:32,030 that is greater than the Y value in P1. 57 00:04:32,930 --> 00:04:38,150 OK, so how can we say which one of them is greater than the other? 58 00:04:38,810 --> 00:04:39,120 OK. 59 00:04:39,210 --> 00:04:46,670 For that, we will need to specify, but exact by exact what fields we want to compare between these 60 00:04:46,670 --> 00:04:49,010 two variables of struct point. 61 00:04:49,610 --> 00:04:52,760 So in this case, that simply won't work because. 62 00:04:54,020 --> 00:04:58,760 We do not specify exactly by what fields we are going to decide the result. 63 00:04:59,460 --> 00:05:06,250 OK, so it may be by one of them, it may be by both of them, it may be by none of them. 64 00:05:06,260 --> 00:05:06,940 I don't know. 65 00:05:06,950 --> 00:05:07,820 It depends. 66 00:05:08,780 --> 00:05:14,690 So up until now, just understand what you cannot do and you should not try to do. 67 00:05:15,230 --> 00:05:17,210 OK, so that's the problem. 68 00:05:17,210 --> 00:05:19,610 Number one, you cannot compare between them. 69 00:05:19,610 --> 00:05:22,100 You cannot ask if one is greater than P2. 70 00:05:24,050 --> 00:05:30,360 The second is also to demonstrate basically, what are you trying to compare? 71 00:05:30,380 --> 00:05:34,850 Are you trying to compare both of these variables field by field? 72 00:05:35,420 --> 00:05:40,190 If that's the case, maybe we can write something down, but not always. 73 00:05:40,190 --> 00:05:41,810 That's the case, will not always. 74 00:05:41,810 --> 00:05:49,010 We compare between two different variables of this same structure, and we want to know and to say that 75 00:05:49,010 --> 00:05:55,100 they are totally equal only if all of their fields are totally equal with one another. 76 00:05:55,430 --> 00:05:56,870 That's not always the case. 77 00:05:57,350 --> 00:06:03,260 OK, I'm going to show you hopefully during these course, a couple of scenarios where this wouldn't 78 00:06:03,260 --> 00:06:03,740 matter. 79 00:06:04,280 --> 00:06:04,660 OK. 80 00:06:05,540 --> 00:06:10,280 So error number two, we don't know what fields are we interested in. 81 00:06:10,310 --> 00:06:12,170 Maybe we are interested in all of them. 82 00:06:12,680 --> 00:06:16,170 Only if all of the fields are equal, then the result will be true. 83 00:06:16,520 --> 00:06:23,840 Or maybe we are just interested in knowing if P1.6 equals to P2 italics, then we can say that for us, 84 00:06:23,870 --> 00:06:25,490 that should be sufficient. 85 00:06:25,490 --> 00:06:33,380 And we can say that both of these variables, B1 and P2 are equal just by saying that if the X members 86 00:06:33,380 --> 00:06:41,510 are equal, then we can decide and we can conclude that both of the variables of struct point are equal. 87 00:06:41,930 --> 00:06:44,240 So we didn't specify it explicitly. 88 00:06:44,240 --> 00:06:46,190 So that's hard to decide. 89 00:06:46,970 --> 00:06:47,420 OK. 90 00:06:48,200 --> 00:06:49,280 So far, so good. 91 00:06:49,790 --> 00:06:57,860 I'm just preparing you for a material that is even more important and not not more important, but also 92 00:06:57,860 --> 00:06:58,670 very important. 93 00:06:59,540 --> 00:07:01,640 So that's about the first example. 94 00:07:01,700 --> 00:07:07,730 Now let's take a look at the second example to make sure that we understand the small details. 95 00:07:08,150 --> 00:07:16,250 OK, so we have these struct struct employee, and this structure is basically it consists of three 96 00:07:16,250 --> 00:07:16,870 fields. 97 00:07:16,880 --> 00:07:19,820 The first field is an array of characters. 98 00:07:20,240 --> 00:07:26,090 The second field is a float age some variable and the third field is end ID. 99 00:07:27,400 --> 00:07:27,760 OK. 100 00:07:27,790 --> 00:07:28,600 Three fields. 101 00:07:28,780 --> 00:07:30,310 The first one is an array. 102 00:07:30,340 --> 00:07:31,860 The second one is float. 103 00:07:31,870 --> 00:07:37,150 The third one is entry I.D. So we want to ask a simple question. 104 00:07:37,180 --> 00:07:44,980 OK, let's take a look at this code that I've added here we have created to object to two variables 105 00:07:44,980 --> 00:07:47,290 of an employee struct. 106 00:07:47,380 --> 00:07:49,180 So we created empty one. 107 00:07:49,510 --> 00:07:55,000 It is a variable of a struct employee initialized with the next values. 108 00:07:55,300 --> 00:07:57,550 OK, and the same we do four empty two. 109 00:07:57,880 --> 00:07:59,380 So the first one is Jake. 110 00:07:59,380 --> 00:08:04,690 He's 24 and a half years old and his ID is one two three. 111 00:08:05,640 --> 00:08:15,900 And we also have the second employee MP to which is John, and his age is 30, and he's IDs three four 112 00:08:15,930 --> 00:08:16,260 two. 113 00:08:17,470 --> 00:08:19,540 OK, so far, so good. 114 00:08:20,470 --> 00:08:29,230 Now what we wanted to know is if we are to compare between these two variables of this structure struct 115 00:08:29,230 --> 00:08:29,740 employee. 116 00:08:30,860 --> 00:08:34,820 Then basically, also this will not work. 117 00:08:35,510 --> 00:08:36,230 OK, I. 118 00:08:38,250 --> 00:08:44,610 Intentionally intentionally giving this emphasis on this topic, because a lot of students, they find 119 00:08:44,610 --> 00:08:51,960 it hard to understand the next topics that you learn, like how to use basically in C- language, how 120 00:08:51,960 --> 00:08:59,240 to use the functions that are related to it in C++ language, how we can and why we should use openly 121 00:08:59,250 --> 00:09:00,690 operator overloading. 122 00:09:01,050 --> 00:09:03,120 OK, so that's just the basics. 123 00:09:03,150 --> 00:09:09,900 Make sure you understand it completely, not just memorizing it, but understanding every step that 124 00:09:09,900 --> 00:09:10,830 we discuss here. 125 00:09:10,860 --> 00:09:12,140 Why is this happening? 126 00:09:12,150 --> 00:09:14,100 Why is it not working and so on? 127 00:09:14,850 --> 00:09:18,690 So we cannot compare if MP one is greater than MP two? 128 00:09:18,960 --> 00:09:23,310 Because by what fields do we exactly compare between them? 129 00:09:23,880 --> 00:09:30,480 Do we compare if MMP one is greater than MP two just by comparing the field of the age? 130 00:09:31,850 --> 00:09:38,420 Or maybe maybe we ask if MP one is is older than MP two. 131 00:09:38,720 --> 00:09:41,780 That's one option, but maybe we want to ask you for MP. 132 00:09:41,810 --> 00:09:49,010 One is greater than you do, then it simply means that we want to compare their IDs who appears before 133 00:09:49,280 --> 00:09:51,890 who in the I don't know, in some book. 134 00:09:52,730 --> 00:09:59,660 OK, and also the same goes for the name which name appears first or maybe will want to take into consideration 135 00:09:59,660 --> 00:10:00,740 all of these fields? 136 00:10:01,400 --> 00:10:04,610 OK, so that's why you cannot work with it. 137 00:10:04,970 --> 00:10:05,510 OK. 138 00:10:06,230 --> 00:10:11,690 And you basically don't know, are they equal by ID, by name or all of the fields? 139 00:10:12,350 --> 00:10:16,820 OK, so that's the problem that we have in the solution to this problem. 140 00:10:17,030 --> 00:10:20,390 I'm going to give you in the next video. 141 00:10:20,420 --> 00:10:21,830 OK, so stay tuned. 142 00:10:22,130 --> 00:10:22,820 Let's go. 13264

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.