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
What is going on, guys?
In this video, we are going to talk about how we can create destructs templates in our programming
language, so.
Here we go.
And the first thing that I want to say is that our computer, lets say and our program knows nothing
about this Trachte we are planning to use.
OK, so we maybe have some idea of some structure that we want to use for the needs of our program.
And if you want to create this new variable of some Newstrike type, then what we should first of all
specify is exactly how the structure should look like before we create a variable of this given structure.
So basically, what we have to do is we have to define the structure of the new struct, simple as that.
And by defining this new struct template, we are simply creating some new box template, OK, just
the template that we can use to create variables of this particular type.
And I'm repeating myself because that's very important to understand the difference between using and
creating the structure template and creating variables and creating these new boxes out of this particular
template.
So you may recall that we've been using simple variables or a standard variables, just like integer
double float char and so on.
And now we are going to use a new way of creating a box template and then creating box variables.
So basically, we already have multiple ready to use types of variables, just like we've seen before.
And that's cool.
And now we want to create our new structure.
So probably we can see that the first step to do so would be, let's say, to create the new structure
so that we are going to use the word struct.
OK, let me use my laser here.
So here you go.
Here you can see struct.
And this specifies this whole structure template specifies not the variable that we are going to use,
but rather adjust the struct template.
So the keyword struct is a building keyword specifying that we are about to use something related to
struct makes sense.
Right.
And there then you specify the structure or name avert it basically generally be like a very descriptive
name for the structure that you are about to create.
When we have these nice curly brackets, the curly brackets actually play.
Here are an important role in defining the structures nature.
OK, the curly brackets simply start a block, OK, a block which describes the fields that we are going
to use as part of the structure.
OK, so you specify the war the keyword struct, then you specify the structure and name using the curly
brackets.
You specify what fields are going to be part of this new structure and these times maybe just like regular.
And if we want to take a closer look, know like to take all of this structure into, look how it will
look behind the scenes.
So basically it will be something like that.
Here are the smaller the smaller boxes, OK, which are just these fields, OK, under the structure.
And we simply take a couple of smaller boxes, OK, smaller boxes and we put them, all of them inside
of this new structure template that we've just created under this structure and name.
No worries, guys.
Once you will understand this concept and you will see a couple of examples, everything will become
much more clear to you.
So no worries.
Just try to keep up the pace and let's proceed.
Let's proceed to our couple of examples.
OK, so the first example that I want to show you guys is the example of creating a date structure.
So simply saying we want to have some new structure that will represent a date in a date consists of,
first of all, day, month and year.
OK, so instead of specifying like date one in day one indeed, two in a day, three in four months,
one month two and so on, we want all of the fields related to a given date be located under one structure.
So we use struct.
We said that.
Is the key word that we are going to use when we use and specify the structure template name in this
case, I want to create a date.
So date is pretty good in here.
We have three fields that are under this structure, so into day and month and into year.
So that's how we create our vele our struct template of date.
OK, and if we want to take a look at a couple of other examples, let's say we wanted to create, I
don't know, like a point.
OK, if you're a little bit into math so you know that you have a point and which consists of X and
Y coordinates.
So you know that a point is just can be represented by an X and Y values.
And you specify indexing Y, you also could have used float X, float Y, double double Y, OK, if
you want a floating point numbers.
So that's also OK.
That's how we create a structure template of point.
So I think everything is clear.
So far nothing complicated.
Right.
We're moving on together to understanding these concepts once and for all.
OK, guys.
So the last example here is, for example, you want to create and to use this part of your program
as awesome future a developer.
Right.
You also want to use some address.
OK, so you want to have a structure that represents an address of some employee, of some person or
I don't know if you're making some application that uses addresses, that may be a good way, maybe
for some applications to store it this way.
So instead of using like char, state of bio, char, city of Beeld, Charge, Charra, state of George
and so on, like for everybody, we are going to create a structure using this structure template to
represent the exact address of any given person that we want to have in our application.
So under this template, we will have the state will give it like 20 characters.
Let's say, for example, we will have this city of ten characters, the street, which is represented
by 15 characters and also will have the number of the street that will be represented as an integer.
OK, so you see, we make here a lot of combinations between different variables and different data
types and putting them all under a new structure template that we created.
And we specify the structure template name here after these structures, throughout the address created
a new struct address, created a new struct point, created a new struct date and one thing.
And it's very important to understand, guys, we just created this video in this video at this stage,
we just created the structure template.
In the next videos, we are going to see how we can create variables, actual variables that are represented
in the memory of our computer and of these particular types, just like we created in today.
OK, whenever you will.
We're using different applications.
You wrote in today and in this step that you wrote in day, you created a new variable date.
So what we are going to do is to create a new date that will consist of these fields and new variable
of type struct date that will have as each bar in today, each month and each year.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.