Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

C++ Tutorial (45 updated 1) - Absolute n00b spoonfeed

Loading...

Sign in or sign up now!
11,981
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on May 26, 2008

Video tutorials about programming in the C++ programming language.

Part 45 update 1:
* more about pointers
* arrays are pointers


Pardon my imperfect english.

Forum: http://cpptutorials.freeforums.org/

If you have any suggestions about how to make this video clearer, more n00b helpful, and explanatory, please send me a message.

If you have any C++ questions, please comment.

  • likes, 1 dislikes

Link to this comment:

Share to:

Uploader Comments (antiRTFM)

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

Top Comments

  • thanks, i finally understand pointers.

    and this video need waaaaaay more views -.-

  • i so agree

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!!!

  • @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,

  • @azkamran Thats called a prefix expression.

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

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

  • @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 =) )

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

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