Design Patterns - Factory Method Pattern Adding More Power to Count Allocated Objects in C++

  Рет қаралды 3,425

Mike Shah

Mike Shah

Күн бұрын

Пікірлер: 17
@georgiosdoumas2446
@georgiosdoumas2446 2 ай бұрын
11:34 , I think that destructor should not have any parameter list!
@MikeShah
@MikeShah 2 ай бұрын
Indeed -- copy & paste error without actually testing (just in the 'discussion' or 'sketch' portion of the video). I'd need to think a bit about a use case for a parameter in a destructor -- perhaps for control flow on how you'd like to perform deletion for instance -- but the mechanism may not work as well as 'defer' or 'scope(exit)' in other languages.
@Maximus98245
@Maximus98245 5 ай бұрын
Hi Mike, great video! Could we have not used the reference count of the shared pointers to tell us how many active objects there are? Or maybe the reference count of the weak ptr associated with the shared ptr ? Thanks! auto ptr1 = std::make_shared(10); { auto ptr2 = ptr1; std::cout
@MikeShah
@MikeShah 5 ай бұрын
We can utilize use_count to tell how many times the pointer is referenced in a single-threaded environment (keep in mind, multithreading will otherwise not make this or 'expired' reliable)
@fozilbekk
@fozilbekk 2 жыл бұрын
hello bro, good job Could you recommend something solid for modern openGL 3.3+ with SDL2 (any website or books) I have googled it but could not get . I mean I am gettingSDL2 with this channel but I want openGl 3.3+ with it.
@MikeShah
@MikeShah 2 жыл бұрын
OpenGL 3.3 - 4.6 videos are coming to this channel soon :) Otherwise, learnopengl.com is a good start!
@heyheyheyhoev419
@heyheyheyhoev419 Жыл бұрын
Hi, Mike! Awesome tut, I have one question: on 3:23 you created copy-constructor in private section of "factory" class, but what is the difference with explicit restriction on copy constructor on next line: FactoryGameObjects(const& FactoryGameObjects o) = delete;
@MikeShah
@MikeShah Жыл бұрын
Effectively the same idea -- one is the pre c++11 way of avoiding copies, and 'delete' is the C++11 and beyond way of doing things.
@heyheyheyhoev419
@heyheyheyhoev419 Жыл бұрын
I spotted your case in one of SDL examples(file or asset handler maybe) , so this question appeared in my mind.
@MikeShah
@MikeShah Жыл бұрын
@@heyheyheyhoev419 Ah great! :)
@dwolrdcojp
@dwolrdcojp 2 жыл бұрын
Is the wrapper the best approach for this problem? Could you store them in a container that gets created with the constructer and push back the shared_ptr when the CreateObject function is called? Then you could use the size function from that container?
@MikeShah
@MikeShah 2 жыл бұрын
Could also use a container to count the number of objects created. I think I would improve the above by using an atomic to keep count at the least.
@1981Praveer
@1981Praveer 9 ай бұрын
@9:35 can't we delete by overloading the delete operator? something like: void operator delete(void* memory){ free(memory);}
@MikeShah
@MikeShah 9 ай бұрын
Could certainly do something like that to track allocations.
@wojciechgrunwald80
@wojciechgrunwald80 11 ай бұрын
can you explain how to further code the fragment with adapter?
@MikeShah
@MikeShah 11 ай бұрын
At some point I'll cover some other patterns like adapter in this series.
😜 #aminkavitaminka #aminokka #аминкавитаминка
00:14
Аминка Витаминка
Рет қаралды 2,6 МЛН
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 16 МЛН
🕊️Valera🕊️
00:34
DO$HIK
Рет қаралды 19 МЛН
Factory Method Pattern - Design Patterns (ep 4)
27:21
Christopher Okhravi
Рет қаралды 551 М.
I made it FASTER // Code Review
38:46
The Cherno
Рет қаралды 545 М.
Python OOP Tutorial 5: Special (Magic/Dunder) Methods
13:50
Corey Schafer
Рет қаралды 863 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Brian Will
Рет қаралды 2,1 МЛН
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 485 М.
Factory Method Pattern Visualized
23:54
Kantan Coding
Рет қаралды 9 М.
😜 #aminkavitaminka #aminokka #аминкавитаминка
00:14
Аминка Витаминка
Рет қаралды 2,6 МЛН