C++ dynamic memory explained for beginners 🧠

  Рет қаралды 19,541

Bro Code

Bro Code

Күн бұрын

Пікірлер: 22
@BroCodez
@BroCodez 2 жыл бұрын
#include int main () { char *pGrades = NULL; int size; std::cout > size; pGrades = new char[size]; for(int i = 0; i < size; i++){ std::cout
@afd128
@afd128 5 күн бұрын
thank you very much, ENG 🤍
@thechudson
@thechudson 6 ай бұрын
This helped me understand pointers so much more than your original video did. Not that your previous vid didn’t make sense, it just feels much more more practically applicable now compared to before. Much thanks
@dynamagon
@dynamagon 2 жыл бұрын
Hey do you think you could do an episode on std::vectors ? I think a lot of people could get a ton of use out of them.
@dc3295
@dc3295 Ай бұрын
bro youre an awesome teacher, thanks so much for everything
@JackEvans-hf7qt
@JackEvans-hf7qt Жыл бұрын
//allocating dynamic memory to pointers and printing the no . of items specified by the user in c++ # include using namespace std; int main() { string *ptr= NULL; int size; string temp; coutsize; ptr=new string[size]; for(int i=0;i
@ngchn64
@ngchn64 7 ай бұрын
Thank you so much!! Wish I found this video sooner
@shivakumark1824
@shivakumark1824 2 жыл бұрын
TQ for your video
@Dazza_Doo
@Dazza_Doo 2 жыл бұрын
I see, this is where the New keyword came from, as you know C# doesn't run without it!
@TheDreamN
@TheDreamN 5 ай бұрын
Would it be better to use vectors instead when unsure of the array size and what it would be?
@heco.
@heco. 2 ай бұрын
Vector it self uses heap memory. In most of the cases, using vector is certainly the best choice since it has a lot of benefits. The only benefit for using normal array in heap memory is that it costs less memory overhead and less processing time. Which is basically negligible. But you could notice it if you're working with very very large memory. So, yes you can use vector here and you should.
@shervin9561
@shervin9561 Жыл бұрын
Heap and stack! thanks
@willlagergaming8089
@willlagergaming8089 11 ай бұрын
#include int main () { int size; std::cout > size; char pGrades[size]; for(int i = 0; i < size; i++){ std::cout
@emilgmelfald
@emilgmelfald 4 ай бұрын
Why do you use NULL instead of nullptr? Is there an important difference between the two?
@heco.
@heco. 2 ай бұрын
NULL is basically the integer 0 but nullptr is a custom keyword made specifically for pointers. In this case, it wouldn't really matter what you use but it's good practice to use nullptr because it's more type safe.
@gvega6227
@gvega6227 14 күн бұрын
How come when you print the value of your pointer pNum, you use *pNum, but when printing the values of pGrades, you do not use the de-referencing operator (i.e *pGrades[i])?
@ujeshasivaramakrishnan2464
@ujeshasivaramakrishnan2464 7 күн бұрын
its because you need de referncing for data types that take up space like int or char while for a container type data type like arrays do not need dereferencing or pointing since we are already pointing to something in the array that is pGrades[i] index position 'i' and for the question of why we are using pointers is because we need to point to array itself as well and hence just for container types we dont need referncing but for int or char we do and pointers for everything PS i dont know if i am right but this is what i understood
@TahaProgrammer
@TahaProgrammer Жыл бұрын
what will happen if i dont delete it
@masterali2837
@masterali2837 Жыл бұрын
A memory leak could happen it means the memory could disapear change other memory get corupted or if not enough memory avaible gets overiden by anotehr memory or vice versa
@HousseinAlDroubi
@HousseinAlDroubi 4 ай бұрын
Hey man.
@alejandrobh797
@alejandrobh797 3 ай бұрын
hi
C++ recursion explained easy 😵
6:21
Bro Code
Рет қаралды 21 М.
C++ pointers explained easy 👈
5:16
Bro Code
Рет қаралды 57 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
Pointers and dynamic memory - stack vs heap
17:26
mycodeschool
Рет қаралды 1,5 МЛН
new & delete Operators For Dynamic Memory Allocation | C++ Tutorial
15:52
Portfolio Courses
Рет қаралды 34 М.
C++ structs as arguments explained 🚚
5:29
Bro Code
Рет қаралды 11 М.
Dynamic Memory Allocation -- C++ Pointers Tutorial [8]
18:25
Professor Hank Stalica
Рет қаралды 30 М.
you will never ask about pointers again after watching this video
8:03
What are C++ FUNCTION TEMPLATES? 🍪
5:15
Bro Code
Рет қаралды 10 М.
C++ TIC TAC TOE game for beginners ⭕
19:09
Bro Code
Рет қаралды 37 М.
C++ How to fill an array with user input 🌭
6:58
Bro Code
Рет қаралды 12 М.
Stack vs Heap Memory - Simple Explanation
5:28
Alex Hyett
Рет қаралды 266 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН