All language subtitles for 18. Composing struct inside another struct

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
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

Original subtitles

Welcome back, ladies and gentlemen.

And in this video, we are going to talk about how we can create structs, new structs which should

hold members that are going to be objects of another glass.

So sounds very, very intimidating, but I think that we are going to be hopefully just fine.

OK, so let us start.

So we had these previous example of one of the common examples that we've talked about, and this example

creates a structure called point in these struct has two members X and Y.

And in this case, both of them are of an integer type.

So this structure is used to represent a simple point with X and Y coordinates.

OK, so a simple point he's basically used to represent, basically that's all the structure is all

about representing points that have X and Y coordinates.

So that's the point.

And now we want to create a new structure called Circle.

And we want this circle to be able to represent a circle.

So how should should it look like if we take a look at the simple circle?

We know that there are a few things that are used to characterize a standard circle.

First of first of all, there is the center point.

And the central point is actually the center of the circle.

It also has the X Y coordinates and also we have the radius that is used to represent the distance between

the center and any of the points on the circle itself.

OK, so do things are used to represent a circle?

So now what we want to do is to create a structure that this structure is going to show us, and basically

it's going to be used as a template kind of a template.

Yeah, of course, template is another topic, but just generally speaking, we are going to use the

circle template.

And the circle structure is the basis for the creation of all of the future objects that we are going

to make in this program or basically just by using these struct.

So it will look like, oops, sorry.

Now this one, the first one, so it will look like this.

OK, well, we'll use index and the Y to coordinates to basically specify the X and Y coordinates of

some point.

And also we'll use double radius to specify.

Their writing is itself of this circle.

It now based on these class that we've just created, we will be able to create instances, right?

We will be able to create variables of this circle structure.

We will be able to create one which would be circle one, C2, C3 and basically access and modify each

of these members.

One by one.

One after the other.

And so on.

OK.

So that's basically what we are going to do, what we can do.

Awesome.

Now, the question is, should we do it this way?

Or maybe there is more elegant way in organizing our project, so we know that X and Y, both of them

are used to represent a point.

Right.

So basically, a circle can be represented as a radius and a center point.

So why should we keep it in extending why?

And basically kind of duplicating the code?

We can make it much more elegant by using the following structure.

So the structure is the same typedef struct circle.

We are using a circle structure.

We're creating this structure and now we are going to use what we are going to use.

Point Center.

What does it mean?

Let's try to understand what it means.

We create a variable.

OK?

We create a variable of type point, and this variable is a member.

It is a field inside of the circle class.

Once again, we create the circle glass inside of this circle, sorry struct, we create a circle struct.

That's something that I teach in another, of course, so forget about it.

We create a circle struct in this part of the struct we use a member of field that is basically a variable

of another struct.

OK.

And we also have another field called radios.

So if we take a closer look, basically the structure of Circle is going to look like this, OK?

It will have main two fields, right?

It is going to have the radius, which is of type double.

And also, we are going to have the center.

Which is of type point?

OK, so that's basically we have these two.

That's the first one.

That's the center and that's the second one.

That's their ideas.

But what we also know is that these center.

It is also of a point type.

And we know that any variable of a poison type has two fields, intakes and entwine.

So if we take a closer look at this one, we will see that it has two fields.

It has intakes and it also has in white oak two fields.

Are we clear?

Awesome.

So now what we can do is basically we can use it to create what can we create?

It's I will simply remove it, you can copy it to your notebook that you will keep some record of it.

Now we can use to see and basically how we can create variables of a circle type.

So first of all, we have point B one and use some initialized zero initializing at this point.

So point B one equals to one and two point B one equals to one and two.

That's just the point that we created.

Here it is.

Here it is.

This is one and it has the values of wanting to be one.

Now we create a circle, see one.

Currently, the center and the radios are not specified, but we are going to specify the sensor and

the radios, so we specify the radius equals to three point three and the center equals to be one.

So it's just going to copy this point.

These members into the center are since both of these structures, both of these variables P one and

C one, the center, both of them are of a point type.

So there is no problem.

There are going to copied one by one field by field.

So let's take a look at it and it's going to look something like that.

So that's going to be three point three.

And this is the C one circle that we created.

OK.

Is it clear?

So once again, we can access.

Various things from an outer variable of type circle, we can access the radius in the center.

And also what we can do is very important to clarify it.

We can access and print.

Let's go like this.

Let's go simply.

Let's simply say that we can access see one dot center.

And we know that center is of a point type.

And we will be able to access.

What can we access the X and Y coordinates, OK, so you can see that we can access X and Y inside of

this center point so we can access X, we can modify it, we can print it, we can read information,

write information into it.

We can also do it for white.

OK.

Because once again, we have see one.

Here it is, see one is the bigger park than we have inside of see one.

We have the center.

Here it is.

And we have the radius.

And the center itself is a member inside of C one.

OK.

It is a field, but this field is also basically it also has some smaller fields inside of it because

it's of type of point and it's a user defined structure that we created.

So these sensor, it also has two fields index and in white, and we can access each in any one of them.

So the way we do that, we can access C1 that center.

So we access this center, remember?

And inside of these member, we can access any of the fields that it contains, changed them, modify

them, reading to them, bring them out and so on.

OK, so yeah, that's very important for you to be familiar with.

And to basically know that you can access this, you can modify, OK, also you can do it for X, let's

say five that you can access and modify these fields and that you can create structures that basically

contain variables of another of structures that you can create one struct that will basically be consist

of another part of structures that you create.

OK, so there are plenty of examples that can be used for it.

For example, you can create, I don't know.

You can create an employee structure, and these employee structures should have a couple of fields,

right?

And one of the fields that it can have is basically the date of the birth of the name of the employee,

and date is also should be struct.

We can also have a date when the employee started working.

We can have something related to specifying, I don't know some information about some status of the

employee by using another structure.

Maybe I will also add some exercise about it that you will be able to work a little bit on this topic.

OK, so but this is the general concept of using it very important.

Make sure you watched this video from the start of the end, and maybe if it's not so clear, I will

add additional exercise.

Maybe I'm not promising.

Hopefully, I will add additional exercise.

But for now, make sure you understood every concept.

Write down this code on your own.

Try to run it.

Try to make sure that you understand everything, how to access everywhere.

And yeah.

Thank you for watching, and I will see you in the next videos.

My name is Vlad Lisa's Alfa tech.

I'll see you in the next video by.

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