All language subtitles for 2. Unions - Variables

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,990 --> 00:00:05,550 Now, let us talk about the need and also the use it for unions. 2 00:00:05,740 --> 00:00:12,420 OK, so I think the best thing we can do right now is to start with a simple example. 3 00:00:12,990 --> 00:00:19,200 Let us see some code snippet with the syntax regarding unions and then discuss what's going on behind 4 00:00:19,200 --> 00:00:19,780 the scenes. 5 00:00:20,700 --> 00:00:23,790 So first of all, how we define a union. 6 00:00:23,790 --> 00:00:32,440 So how to define to define a union, how we basically will define it in our programming language. 7 00:00:33,900 --> 00:00:39,060 So first of all, we are going to use the union key word. 8 00:00:39,240 --> 00:00:40,980 So that's going to look like this. 9 00:00:41,250 --> 00:00:50,940 So, Union, OK, this this is a saved key word that will specify that now we are at the process of 10 00:00:50,940 --> 00:00:55,770 defining the union and then we will specify the union name. 11 00:00:56,040 --> 00:00:59,100 OK, here will be the union name that we will choose. 12 00:00:59,140 --> 00:00:59,300 Okay. 13 00:00:59,320 --> 00:01:01,800 I'm just showing you now the template. 14 00:01:01,800 --> 00:01:08,960 That's not an actual definition because we will have to replace here these union names with a real name. 15 00:01:09,790 --> 00:01:16,040 Now what we are going to do is to specify inside of these union some data type one. 16 00:01:16,050 --> 00:01:24,980 OK, so data type one and field one and then data type two and field two and so on and so forth. 17 00:01:25,260 --> 00:01:27,660 So field two and so on. 18 00:01:27,810 --> 00:01:33,600 OK, so that's basically the definition of a union. 19 00:01:33,630 --> 00:01:35,120 OK, that's the template. 20 00:01:35,460 --> 00:01:42,960 And if we want to take a look at some example of how basically a real union can be defined, so let 21 00:01:42,960 --> 00:01:44,350 us use something like this. 22 00:01:44,370 --> 00:01:50,610 OK, so union, that's the first key word union and then we'll specify its name, let's say invoke. 23 00:01:51,150 --> 00:01:54,250 And I will also say what will be its fields. 24 00:01:54,270 --> 00:01:57,500 OK, so let's create an array of characters. 25 00:01:57,510 --> 00:02:05,820 So Charr first name with 20 characters and also let's create additional variable, let's call it, I 26 00:02:05,820 --> 00:02:06,640 don't know, age. 27 00:02:06,660 --> 00:02:12,540 OK, so we created a union called Info and it has two fields. 28 00:02:12,930 --> 00:02:18,390 The first field is first name and that's an array of characters of size 20. 29 00:02:18,840 --> 00:02:22,440 And also we have age, which is an integer. 30 00:02:24,410 --> 00:02:30,610 All right, so what do you also can do, you can create any other union that you want to know, union 31 00:02:30,820 --> 00:02:33,800 or I don't know, mean remarks. 32 00:02:34,180 --> 00:02:37,730 OK, I don't know something like this, Reverend. 33 00:02:37,750 --> 00:02:38,740 Whatever you decide. 34 00:02:38,980 --> 00:02:39,700 And here he is. 35 00:02:39,700 --> 00:02:40,720 Two variables. 36 00:02:40,990 --> 00:02:41,380 Oops. 37 00:02:41,380 --> 00:02:42,210 Sorry about that. 38 00:02:42,220 --> 00:02:47,650 Ain't mean and ain't MOCs and I don't know, double average. 39 00:02:47,660 --> 00:02:48,030 I don't know. 40 00:02:48,040 --> 00:02:54,700 Whatever you want you can use is as part of the fields of this union. 41 00:02:55,420 --> 00:03:02,170 And we will see the differences between these unions to structures because there is a difference, there 42 00:03:02,170 --> 00:03:02,890 is a difference. 43 00:03:02,890 --> 00:03:10,030 And that's what we are going to discuss right now because of the creation of the union is pretty similar 44 00:03:10,030 --> 00:03:11,460 to how we used strong. 45 00:03:11,590 --> 00:03:11,820 Right. 46 00:03:11,830 --> 00:03:17,710 Because we simply used here like struct in marks and then we created some fields. 47 00:03:17,710 --> 00:03:26,800 So union definition, the definition of a union is very, very straight, very, very similar to the 48 00:03:26,800 --> 00:03:34,720 structure, but is actually quite what has quite differences behind the scenes. 49 00:03:35,620 --> 00:03:43,180 But before we do so, OK, before we do so, this first of all, just remove this, I don't know, this 50 00:03:43,180 --> 00:03:45,550 template, OK, or basically let's go and do it. 51 00:03:45,880 --> 00:03:47,160 Let's make that comment. 52 00:03:47,530 --> 00:03:57,280 So this will be a long comment, but will specify the template for creating a union. 53 00:03:57,550 --> 00:04:01,120 At least it will be some union that we will use for these examples. 54 00:04:01,190 --> 00:04:07,270 OK, so now before we will proceed and dive into what's happening behind the scenes, I will also use 55 00:04:07,270 --> 00:04:10,750 some drawing, some visualization to make it more clear to you. 56 00:04:11,200 --> 00:04:21,130 What I want us to do now is just to focus on basically how we can create a variable of these user defined 57 00:04:21,130 --> 00:04:24,640 type of this union that we just created, this union info. 58 00:04:25,710 --> 00:04:33,870 So if we want to create a variable of some user, a defined union type, then in this case it will look 59 00:04:33,870 --> 00:04:34,270 like this. 60 00:04:34,290 --> 00:04:37,530 OK, so let's write also down the template. 61 00:04:37,630 --> 00:04:40,150 OK, so that's the template of running it. 62 00:04:40,440 --> 00:04:47,790 So first of all, you specify union and the union name, union the name, and then you specify also 63 00:04:47,790 --> 00:04:48,720 the variable name. 64 00:04:49,810 --> 00:04:57,870 OK, so that's basically the main template for creating a variable, OK, creating a variable template 65 00:04:58,170 --> 00:05:04,170 for creating a union variable. 66 00:05:04,800 --> 00:05:07,760 OK, a union that has already been defined. 67 00:05:08,520 --> 00:05:12,100 So in our case we will simply use something like this. 68 00:05:12,120 --> 00:05:20,100 So you need lenfilm union info and let's say, I don't know my variable, let's go with my variable, 69 00:05:20,530 --> 00:05:21,960 my variable one. 70 00:05:22,800 --> 00:05:27,300 So this will create a new variable called my variable one. 71 00:05:27,300 --> 00:05:30,150 And it's going to be of type what type? 72 00:05:30,540 --> 00:05:31,650 Union info. 73 00:05:31,950 --> 00:05:33,590 OK, nothing special. 74 00:05:33,600 --> 00:05:37,470 And these type, you know how it looks like behind the scenes. 75 00:05:37,680 --> 00:05:45,360 Basically, that's its definition and how it really represented in terms of like visually we are going 76 00:05:45,360 --> 00:05:46,650 to see right away. 7153

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