Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
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.