Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (3)

Sign In or Sign Up now to post a comment!
  • 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.

  • 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

  • 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.

  • 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?

  • 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.

  • Remember to network with other programmers! Add me to your network! subscribe. Im here to help

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more