0x00 How to C++ Dynamic memory tutorial Advanced topic HD Full coding video
Loading...
1,820
Loading...
Uploader Comments (samljer)
Video Responses
This video is a response to C Programming Tutorial - 9 - Do While Loops
Loading...
Dynamic memory is something that isnt set aside at compile time, where as hard coded is...
For example, your program loads a dbase from file when started
you dont know the number of classes or even INT array or whatever you would need.
the only way to have an array for example that can change in size in your code, would be to make it dynamic in memory
EX2:
You cant have dynamically changing memory without making it dynamic in the first place.
-- Arrays that change size while running.
samljer 2 years ago
Yea I've watched some Standford c++ lectures about memory allocation and much more.
But combining their explanation and your video + comments made it pretty clear now, thanks.
Still struggeling abit with using it but it'll take some time to fully understand it i guess :p
novaatje 2 years ago
This is what i did to grasp it.
Write a program that picks a random number
then creates an array of that size.
then fills it with random numbers.
Accomplish that, and your golden.
samljer 2 years ago
I've got a question. Why whould you dynamic memory? I mean, whats the difference betweeen these 2:
int main(){
int a = 100;
int *b = new int;
*b = 100;
}
It looks the same for me.. (dont blame me, im used to PHP :p)
Can you maybe give a good example why you need dynamic memory?
novaatje 2 years ago
Another thing to keep in mind is
if you SOMETIMES need a variable while running and sometimes DONT
int a = 100; "always exists, always takes up memory"
int *a = new int;
a = 100;
(int a) now only exists if u need it to
Not all programs will execute all branches of code.
samljer 2 years ago
Remember to network with other programmers! Add me to your network! subscribe. Im here to help
samljer 2 years ago