Added: 3 years ago
From: antiRTFM
Views: 11,973
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
see all

All Comments (25)

Sign In or Sign Up now to post a comment!
  • It is interesting that definining an array:

    int arr[3]; // as an example

    is equivalent to this:

    int a;

    int b;

    int c;

    int * const pointer = &a;

    So it means that such sintax just simplifies allocation of many bytes. The "const" word in pointer definition means that ones we gave an address to this pointer, we cannot change it ever. Also, it is important to note that allocation of arrays is made in a stack memory (check the adresses - they are reduced when you go further, indexing an array!).

  • Is there any way we can change an address that is set?

    e.g. int * ptrCow; ptrCow = 0020FA98; // sets ptrCow to point to an address typed in

  • oh yeah, btw... is it possible to change the ADDRESS of a variable or something like that?

  • man... on the previous video, you made me more confused about pointers towards the half way mark and onwards... THANK GOD YOU MADE THIS VID TO GO WITH IT!!!

  • you can also use ++*ptr instead of (*ptr)++

  • @azkamran, placing the increment operator before the derefrenced pointer just incriments its value, then returns it. As opposed to returning its value, then incrimenting it. therefore, the need to use one or the other is based on the necesity of the situation. not which one is better.

    (i write ths comment assuming you said to use the pre-fix incriment because you thought it was better. If you said it just to put it out there, the you now have a little more knowledge either way =) )

  • @bandos4lyfe sorry about my spelling errors on increment =\

  • it also increments it based on its base class's memory foot print. Its kinda interesting IMO.

  • @azkamran Thats called a prefix expression.

  • Comment removed

  • I feel so accomplised finally understanding pointers. :D Now off to passing by reference!

  • I understand that when you use pointers, you are not copying variables. However, I do not get why you would NEED to do it. Why do that instead of copying variables? And in what cases will I NEED to use pointers? This question has been bothering me for months now.. So please help me. Thanks.

  • you will need for memory management.

  • @Chaser202 Lets say you only used copied variables to get from the main function to function b. The only way to get the result of function b back to the main function is to "return" it. You would be limited to returning only one variable/result per function ("return" only works once, after that the function stops) The only way to get multiple results from one function back to the main (or to any other function) is via the method discribed in this video (pointers).

    Cheers,

  • Very nice! 5 stars.

  • thanks, i finally understand pointers.

    and this video need waaaaaay more views -.-

  • i so agree

  • lol, agreed--i NEVER could understand pointers--this is the first time it's clear to me =)

  • me either... yaaay

  • in the last video i didn't understand why the increment hasn't take place...ok we r in local world but as we jump to first function ie incremented(var) we have the incremental operator there.....why that x++ cudn't help here...thanks

  • as explained, the 'x' that is being incremented is a completely different variable than the original one we passed by value. Sure, the local 'x' will definitely be incremented, but not the original one from the other function.

  • if i was to get something that listed memory addresses can i alter them?

    ur tutorials rock !!

  • I just found your videos and you explain good man :)

    can you tell me how do we know when to return a & or a const function and when not to retunr one? this is a confusing issue!

  • that's called a "reference" as we will (hopefully) learn about soon

  • u the best

  • pls. do 46 soon

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