C++ Constructor & Destructor (with use of make_unique, unique_ptr, and auto_ptr) Tutorial

preview_player
Показать описание
In this tutorial, I will walk you to the process of making a constructor and destructor. I will also demonstrate to you how to use make_unique, unique_ptr, and auto_ptr to perform automatic memory management for you.

Please be sure to press like and subscribe.
Рекомендации по теме
Комментарии
Автор

Great video, easy to understand. i still got a problem tough.. i'm trying to allocate a private member vector of unique_ptr to a base class object ( m_objects ; ) and than to pushback derived classes into it trough a void function that gets nothing and returns nothing but it knows the vector member in the private section of the class because the cpp file belongs to its header file so i use ( <Derived1>(); ) but i always get these linkage errors 2019 and 1120 and i don't know what to do anymore..

alexbutane
Автор

Obviously, using this-> in member functions to to refer to member data works, is legal, and everyone should know how to do it. However, it is normally considered poor style to force yourself to need to do that by choosing parameters to these functions or creating local variables in these functions with names identical to members. While there is no one style that everyone agrees on universally, definitely overuse of this-> due to self-inflicted naming conflicts does seem to be frowned on. Not that this is what the video is about, but hey, hundreds of people (at least) are watching these videos, so please think about that.

I'm going to also chime in with those who say auto_ptr<>: is kind of deprecated now, for unique_ptr<> and shared_ptr<> altho the only C++ code I'd ever been paid to help maintain indeed still used them, it was pre-C++ 2011 code...

jvsnyc
join shbcf.ru