background top icon
background center wave icon
background filled rhombus icon
background two lines icon
background stroke rhombus icon

Download "Порядок вызова деструкторов при наследовании. Деструкторы. ООП C++ Для начинающих. Урок #101"

input logo icon
Video tags
|

Video tags

как научится программировать
для начинающих
c++
C#
java
html
pyton
для новичков
для чайников
научиться программированию
курсы программирования
уроки
массивы
функции
циклы
builder
visual studio 2017 уроки
visual studio
web программирование
программист обучение
#SimpleCode
как стать программистом
javascript
с нуля
порядок вызова
деструкторы с++
наследование
ооп
пример
зачем нужен
как вызвать деструктор класса
наследование конструкторов и деструкторов
Subtitles
|

Subtitles

subtitles menu arrow
  • ruRussian
Download
00:00:02
continue to study programming
00:00:03
using the example of the C plus plus language in one of the
00:00:06
previous lessons we looked at
00:00:08
what happens during the destruction of a
00:00:10
class object, namely at the moment
00:00:13
when the class object goes out of
00:00:17
scope or for some reason a method or
00:00:20
a function, or the same
00:00:22
main function, and you and I know that at this moment
00:00:24
the destructor is called,
00:00:25
which is cool, but what will happen
00:00:28
if we have such a class inherited from
00:00:33
other classes, and such a chain of
00:00:35
inheritance can have a rather
00:00:37
long form, for example with ours
00:00:40
class c from the last lesson which she on
00:00:42
the left is inherited from geoby
00:00:44
hotel we will look at the answer to this question today
00:00:47
in this video and before we
00:00:49
start I want to remind you that next to the
00:00:52
button to subscribe to the channel there is a
00:00:54
special bell by clicking on which
00:00:56
you will not miss any new video
00:00:58
that comes out on the channel because you
00:01:00
will receive a notification about this that I
00:01:02
recommend that you click this bell
00:01:04
Well, we will continue and actually
00:01:07
our task for today is to determine
00:01:10
how destructors are called when
00:01:13
destroying class objects. In
00:01:16
fact, while we have the simplest
00:01:18
primitive classes in principle then we don’t
00:01:21
care in what order they are called,
00:01:23
but if you and I have a complex
00:01:25
class structure and, for example,
00:01:27
memory is dynamically allocated in these classes or
00:01:29
some resources are requested that
00:01:31
need to be freed, then this moment
00:01:33
will become critically important for us, but more on that in
00:01:36
future lessons today we are talking specifically
00:01:39
about the order of calls to the destructor in
00:01:42
order to find out how
00:01:43
the destructor is called, it is
00:01:45
enough to implement such a destructor in
00:01:47
this way
00:01:53
and at the destructors moment of its highest we
00:01:57
will output to the console a record that
00:02:00
such a destructor was called,
00:02:02
let's implement these destructors for
00:02:04
all classes
00:02:10
actually Now we can carry out our
00:02:14
experiment, as I already said,
00:02:16
the destructor is called when a
00:02:18
class object goes out of visibility or
00:02:22
some function or method but or the
00:02:24
main function, for example, and in this case,
00:02:27
the destructor for any object of our
00:02:29
class will be called
00:02:30
here at the moment completion of our
00:02:34
program, more precisely, even here at the moment of
00:02:35
calling the keyword are torn
00:02:37
because at this moment we will exit the
00:02:39
my functions, let’s first create a
00:02:41
class object and to check that in
00:02:44
general everything works correctly for us, this is
00:02:45
our simplest class and
00:02:48
when we create
00:02:50
the constructor is called when it leaves the scope of the
00:02:52
may on the destructor is called
00:02:54
let's now change our class pain
00:02:58
a-class b-class by we have inherited from
00:03:01
and and as you remember, in general, when
00:03:05
inheriting we have this
00:03:07
picture glosbe includes and classic
00:03:10
c we won’t talk about it yet so
00:03:12
when we create an object of class b at
00:03:16
the moment of calling the constructor of class b
00:03:17
class b calls the class constructor this is
00:03:20
material from the last lesson
00:03:22
in fact in our class b there will
00:03:25
be a class so that kvass can
00:03:27
interact with it use its
00:03:29
function Well, let’s add here another
00:03:31
seal like this
00:03:32
with two double ones so that we can
00:03:36
see it better and run our program.
00:03:40
Look at the moment of creating our class
00:03:44
b, the constructor of the class is called, then the
00:03:46
constructor of class b is called
00:03:48
because we have copies of the atlas at the
00:03:51
moment when our the object
00:03:54
in this case is in or out of the
00:03:57
scope of the main function,
00:03:59
the destructor is called for it
00:04:00
and then the destructor of the class is called,
00:04:04
hey,
00:04:05
the destructor is always called in the
00:04:07
reverse order by the constructor, that is,
00:04:10
in fact, we parse the class in reverse
00:04:13
order, it’s like a nesting doll, that is, so that in
00:04:17
this case, so that parse the class hey,
00:04:20
which for us is actually
00:04:22
a component of class b, we need to first
00:04:25
parse glosbe,
00:04:26
so we parse glosbe, then
00:04:31
parse the class kai in the reverse order,
00:04:35
if we, for example, create an object of the
00:04:38
class goal, then everything will be
00:04:40
virtually identical in the same form
00:04:42
only in longer options
00:04:45
because our inheritance chain is longer than us
00:04:47
class c inherits from class b b
00:04:49
inherits from class a therefore
00:04:51
the constructor is called first and although we create an
00:04:54
object of class c we first call
00:04:56
the constructor and then b then c because
00:04:58
they are all its components
00:05:00
a person with the components of class c, when
00:05:04
destroying an object of class c, we
00:05:06
actually begin to disassemble this class c
00:05:09
like a nesting doll or unwrap it
00:05:12
like candy, we first kill the class
00:05:15
c itself, we destroy it, that is, if we follow
00:05:18
these are the pictures we take and this is what we
00:05:21
remove when we take pictures in this
00:05:25
shell the class c itself we still have
00:05:27
class b class and in this we
00:05:30
parse class b
00:05:34
after we have taken it we can
00:05:36
start parsing the class and in fact
00:05:39
what we are doing here
00:05:44
in the end we have the order of destruction of a
00:05:48
class object in the reverse order its
00:05:51
creation, but it’s like a pyramid, we can’t
00:05:53
pull out the lowest cube from our pyramid,
00:05:55
we have to do it in reverse
00:05:59
order, otherwise everything will fall apart, everything
00:06:01
will stop working, this is the logic
00:06:04
and scheme for calling
00:06:05
class destructors during
00:06:08
inheritance, and that’s
00:06:10
all I have for now if you liked this video
00:06:12
was useful and interesting to you, don’t
00:06:14
forget to like it and
00:06:15
share this video with your friends,
00:06:17
this will greatly help the
00:06:19
development of the channel because you just see
00:06:21
more people and of course, if you haven’t
00:06:23
subscribed to the channel yet, then subscribe for a long time
00:06:25
so that don't miss the
00:06:26
next lesson and close the bell don't
00:06:28
forget to thank you all for your attention bye

Description:

Понравилось видео или оказалось полезным? Подпишись! Поддержка канала https://www.patreon.com/SimpleCode Порядок вызова деструкторов при наследовании. Деструкторы. ООП C++ Для начинающих #101 Порядок вызова конструкторов при наследовании. Как вызываются конструкторы. ООП C++ Начинающим #100 https://www.youtube.com/watch?v=sNInKQgUZMA&list=PLQOaTSbfxUtCrKs0nicOg2npJQYSPGO9r&index=118&t=17s Уроки по программированию Наша группа ВК https://vk.com/smplcode Подписывайтесь на канал https://www.youtube.com/channel/UCtLKO1Cb2GVNrbU7Fi0pM0w

Preparing download options

popular icon
Popular
hd icon
HD video
audio icon
Only sound
total icon
All
* — If the video is playing in a new tab, go to it, then right-click on the video and select "Save video as..."
** — Link intended for online playback in specialized players

Questions about downloading video

mobile menu iconHow can I download "Порядок вызова деструкторов при наследовании. Деструкторы. ООП C++ Для начинающих. Урок #101" video?mobile menu icon

  • http://unidownloader.com/ website is the best way to download a video or a separate audio track if you want to do without installing programs and extensions.

  • The UDL Helper extension is a convenient button that is seamlessly integrated into YouTube, Instagram and OK.ru sites for fast content download.

  • UDL Client program (for Windows) is the most powerful solution that supports more than 900 websites, social networks and video hosting sites, as well as any video quality that is available in the source.

  • UDL Lite is a really convenient way to access a website from your mobile device. With its help, you can easily download videos directly to your smartphone.

mobile menu iconWhich format of "Порядок вызова деструкторов при наследовании. Деструкторы. ООП C++ Для начинающих. Урок #101" video should I choose?mobile menu icon

  • The best quality formats are FullHD (1080p), 2K (1440p), 4K (2160p) and 8K (4320p). The higher the resolution of your screen, the higher the video quality should be. However, there are other factors to consider: download speed, amount of free space, and device performance during playback.

mobile menu iconWhy does my computer freeze when loading a "Порядок вызова деструкторов при наследовании. Деструкторы. ООП C++ Для начинающих. Урок #101" video?mobile menu icon

  • The browser/computer should not freeze completely! If this happens, please report it with a link to the video. Sometimes videos cannot be downloaded directly in a suitable format, so we have added the ability to convert the file to the desired format. In some cases, this process may actively use computer resources.

mobile menu iconHow can I download "Порядок вызова деструкторов при наследовании. Деструкторы. ООП C++ Для начинающих. Урок #101" video to my phone?mobile menu icon

  • You can download a video to your smartphone using the website or the PWA application UDL Lite. It is also possible to send a download link via QR code using the UDL Helper extension.

mobile menu iconHow can I download an audio track (music) to MP3 "Порядок вызова деструкторов при наследовании. Деструкторы. ООП C++ Для начинающих. Урок #101"?mobile menu icon

  • The most convenient way is to use the UDL Client program, which supports converting video to MP3 format. In some cases, MP3 can also be downloaded through the UDL Helper extension.

mobile menu iconHow can I save a frame from a video "Порядок вызова деструкторов при наследовании. Деструкторы. ООП C++ Для начинающих. Урок #101"?mobile menu icon

  • This feature is available in the UDL Helper extension. Make sure that "Show the video snapshot button" is checked in the settings. A camera icon should appear in the lower right corner of the player to the left of the "Settings" icon. When you click on it, the current frame from the video will be saved to your computer in JPEG format.

mobile menu iconWhat's the price of all this stuff?mobile menu icon

  • It costs nothing. Our services are absolutely free for all users. There are no PRO subscriptions, no restrictions on the number or maximum length of downloaded videos.