Added: 4 years ago
From: ryutenchi
Views: 11,381
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (20)

Sign In or Sign Up now to post a comment!
  • what happened to the delete part with out it its gonna give massive excpetion

  • You know, from a coding perspective this is really tedious to go through the entire dynamic array process every time one is needed- why not just add a library/function for it?

  • hi.... where did you download ur type of C++ programming from?

    i have a 64 bit computer and it wont let me run a c++ program..it says it only runs in 32 bit computerss :(

  • Sorry, Didnt mean to make my last comment sound that way. i just re-read it.

    What i mean is the other video sticks on topic, and doesnt cloud the new guy with additional information such as a FOR loop.

    it actually TEACHES dynamic memory, as an advanced topic expecting basic class/loop knowledge already "as probably should when covering a more advanced topic like dynamic memory use"

  • So how do we resize dynamic arrays, keeping the old values?

  • you have to use a temp. pointer then you can set the array to a new Whatever[newsize]; and copy the values over from the temp point. I know it's a bit complex but there is no build-in method so that's the best way to do it with this method. Alternatively, you can use the *allac C commands to create/size/resize a pointer and then delete them with the free command.

  • Yes, I figured out that in the start, but I had some mistake and I though there is another way, but it seems I was right Thanks ;-)

  • @t3hdewd Use vecotrs or just malloc away.

  • how to make a 2d dynamic array of string data type ? i have an assignment of it i dont know howto make it? any help will be appreciated

  • thanks man. that's really helped.

  • i hope u understand my question here it goes:

    I set an array for example:

    int number[1]; the i set number[0]=100, number[1]=200.

    Is there any way to change number[0] to different number while running the program?

    if so let me know

    thx

  • First, "int number[1];" will only have 1 "slot" in it, so "number[1]=200;" will through an error.

    Second, it is only number of items in an array that you can not change(and that's not always true, but is out of scope). You can change the values at any point so

    number[0]=100;

    if(blue)

     number[0] = 42;

    else number[0] = 73;

    is perfectly valid. hope that helps.

  • @ryutenchi wow, this was quite some time ago. I passed my C++ course, lol. Thanks!

  • Clearest Quality ever

  • Under tutorial about polimorphism I asked in comment about pointers and what made me confused was that "new" word. So:

    character* me; // pointer to an adress in memory

    me = new Player();

    Last line makes compiler to look at the constructor "Player()" of the "character" class and then write a NEW set of arguments stored in this constructor into the memory at the adress pointed by "me".

    You've created an instance of the "character" class but straight into the memory at the "me" adress :).

  • Not quiet.The character class pointer"me"is set up as a generic character pointer that can be used to access any of the public functions or variables of a character,but since we then make an instance of Player and set it equal to it, it now is actually a player,but we only have access to the functions and variables that were inherited or redefined from the base class(character).So polymorphism lets me make a base class pointer and then point it at an object of a derived class at anytime.

  • Hello , I am a begginer and I want to start

    which of your videos should I start from?

  • how about the first one? they have each a unique number ;)

  • nicely done, you have no ideea for how long i've been dieing to find out how to make dynamic arrays. You are making great tutorials keep it going

  • Ah, didn't see that either but it says: 4Please give me the age of the person number 2.

  • not a problem^^ glad you are paying attention. if there is a problem I need to know about it, right? Thanks for watching so closely!

  • when u ran the program the first time, the 2nd age was different.

  • no, if you notice I typed that inital 4 faster then it output the second line to the screen, so if you pause it and look at the beginning of the line you'll see that 4. the cin looks at your input upto the [Enter] so even if you type before it gets all the text to the screen that "4" or whatever is already in the input buffer and then when you press [Enter] it flushes that buffer to that variable.

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