Комментарии:
Let's say you have a 2D pointer array of objects and the pieces in the array is dynamically allocated. Why would it be a terrible idea to "delete" a specific entry, arr[i][j] and attempt to assign nullptr afterwards to that entry? I attempted that with a specific piece of code in my chess game in the one case it caused a segfault and the other case it functioned seemingly fine. I am new to C++ so this is a bit confusing.
ОтветитьPlease do NOT use new/delete to dynamically allocate/deallocate memory in production code. Use smart pointers (std::unique_ptr, std::shared_ptr with the helper functions std::make_unique and std::make_shared) instead. By the way, avoid using namespace std; and use nullptr instead of NULL.
ОтветитьThanks for making video!
If base adress is 0x0001,
ptr_to_ have to be allocated 0x0001+ sizeof(int)?
My God, if I had just watched this 15 minute video before starting my project it would eliminate like 2 hours of confusion...
ОтветитьJust out of curiosity, what is the font used for coding in this video? It looks quite pleasant to me.
Ответитьamazing video !
ОтветитьIve been learning C++ as a 1st year CS student from around 5 months now and Im currently dealing with pointers from my book resources. I was very confused about the concept of new and delete operators and was wondering why I should use them and now Im starting to understand their functions and how important they are on memory management, thank you so much!
ОтветитьThank for this tutorial. But I couldn’t find out a tutorial of yours on placement new. Please can we have a tutorial on that whenever you have time. Thank you once again.
Ответитьim too dum to understand any of this
ОтветитьFantastic
Ответитьgreat
ОтветитьThe clarity of this video is beyond incredible. Fantastic work!
ОтветитьFrom the bottom of my heart, thank you SO MUCH for this. I have been having the hardest time understanding pointers because no resource I had found was hitting quite the right spot on why we should care about pointers, but you did it.
Thank you for taking the time to demonstrate the memory allocation and your attention to discussing that side of things. I have been pulling my hair out over this, and I cannot tell you how overjoyed I am to have found this video.
are you an angel? ive been trying to understand this for days and you're the only one that made it make sense
ОтветитьWould it not be better to declare the big_array pointer out of the try-block and initialize it with a nullptr? After the allocation happens and the main terminates, this is going to result in a memory leak.
ОтветитьI love the commented diagram you made below the code. Really helped a bunch of stuff click.
Ответитьbest explanation about dynamic mem allocation
Ответитьoh shit this tutorial is so good -_- u deserve millions of subscribers
ОтветитьWhat is the editor name?
ОтветитьThanks!
Ответитьgreat playlist , you are a hidden gem!
Ответитьint x = 5;
int *y = &x; //s1
int *y = new int(x); //s2
Sir, what is difference between s1 and s2 ?
Hey man, thanks for making c++ playlist, Which IDE are you using ?
Ответитьdidnt you cover this topic in previous videos?
Ответить