Added: 2 years ago
From: xoaxdotnet
Views: 37,375
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
see all

All Comments (80)

Sign In or Sign Up now to post a comment!
  • Thank you for this, friend.

  • ur videos r so awesome. hope u make more. Great job!

  • WTH ? (What The Heck ?)

    this is the best tutorial in the youtube!!

  • Why should we use a Reference and Pointer?

  • Great video but you sound like napoleon dynamite :p

  • Pointer pointing to a pointer?

    pointerception.

  • Comment removed

  • I'd like to see you do some more practical applications at the end of each lesson. My newb self is still having trouble figuring out a practical application for pointers, although I know what "they are" and "how to code them". Just not sure why I'd use them...

  • I'm a fan, thanks for the help

  • love the videos, but the intro music is so annoying!

  • It's easy for me to understand,and it's clear!

    謝謝製作這部影片的老師^ ^

  • i've been trying to figure this shit out for the past 10 hours for a project due tomorrow. i just watched this and in like 10 minutes i got it. thank you

  • ok i still dont understand 2:25

    ok so what i see is

    the "ipPtrToInt" has the address of "iAnotherInt"

    and the value of "iInt"

    but when the value of "iAnotherInt" is called it's 10?

    how does the "iAnotherInt" change its value?

    please someone help me im really trying to understand, i read through all the comments and replayed that part 10+ times.

  • @Slynas oh wait i just read that and i think i answered my own question but heres another one:

    all the variables were declared at the start so i imagined them all 3 at different locations and the pointer pointing to addresses and values.

    For "iAnotherInt" to accually take the value "10" it means the pointer replaces that memory with the value

    it doesnt accually point?

  • @Slynas What is happening is that the pointer is set to point to iAnotherInt, so it contains the address of it. Notice on the second to last line that he uses the dereference operator. This means that you aren't taking the pointer itself but rather, the variable that the pointer points to. Since the pointer points to iAnotherInt, and we are setting this to iInt, which is 10. This line is just like saying "iAnotherInt=iInt"

    Hope I helped, I suck at dumbing stuff down.

  • @kdmq ooooooohhhh now i get it i thought it took the value of the pointer as it used that variables name but now i see it takes the value that it points to, thank you! now i see why pointers can be useful

    ahhh i feel so dumb he accually says it at 1:59 *facepalm*

  • @kdmq This is the graphical part i made

    section 1 declaring variables: int* ipPtrToInt = 0 ; int iInt = 10 ; int iAnotherInt = 20 ;

    section 2 ipPtrToInt =&iInt;

    section 3 ipPtrToInt = &iAnotherInt;

    section 4 *ipPtrToInt (with the multiplication dot actually this "ipPtrToInt" pointer is "iAnotherInt" since "iAnotherInt" was the last direction he went changing "iAnotherInt" value to "iInt" value that its 10) =&iInt;

  • @Slynas ok, this took me 1 hour to understand so here is is my explanation,

    first section is declarin variables and pointers, second section "ipPtrToInt EQUALl OR IN OTHERS WORDS POINTING TO iInt value that its 10", third section "ipPtrToInt EQUAL OR IN OTHERS WORDS POINTING TO iAnotherInt" fourth section " *ipPtrToInt EQUAL OR IN OTHERS WORDS POINTING TO iInt".

  • @Slynas Note that in section 2 and 3 the pointer " ipPtrToInt " doesnt have the multiplicacion dot ( * ), and in section four the pointer " *ipPtrToInt " have the multiplication dot, this mean in section 2 and 3 the pointer " ipPtrToInt " is pointing or going to to "iInt" and then "iAnotherInt", since "iAnotherInt" was the last variable he went to, in the 4 section when the pointer " ipPtrToInt " was added a multiplication dot, it mean that the last direction variable he went,

  • @Slynas its variable will become iInt value and that value is 10. hope u understood my explanation, its hard for me to explain with this youtube gay characters per post limit.

  • @drakion1989 And yet you have spare characters free to complain about the lack of characters. I think I detect a hint of irony.

  • Comment removed

  • Comment removed

  • mew2king faved this so i clicked on this lol

  • When should I use pointers over references (and vice versa)? Thanks.

  • Hey, is it possible to download all your episodes through one file?

    Or have you only uploaded them on Youtube?

  • its mind blowing to know that this compilation of 3 minute videos are taking an absolute shit on my 80 minute lectures at school, i am honestly so grateful for this entire collection, thank you

  • @R1pTheJacka TRUE I SWEAR TO GOD SO PROFS SHOUDLN'T TEACH AT ALL PROGRAM IS LIKE MATH U GOTTA SHOW EXAMPLES DOP QUESTIONS NO SOMNE FUCKING POINTLESS LECTURE ABOUT BLABBING ALL THE TIME

  • does c++ reference and pointer are similar to VB byref and byval ?

  • @bojanglesme

    c++ pointer can also be point to other ,reference cant so i think the answer is no.

  • If we have pointers, then why do we need to use references in the first place?

  • Pointers and References are very useful and powerful. It's very important not to get hung up on the reason for pointers too early (they will just confuse you). One thing to note is that (where possible) all data members of functions/classes should be kept private. Try to understand how to use pointers/references and as you progress on your journey through the world of C++, all will become clear.

  • Arg pointers are sooo getting me stuck. I just can't think of a reason to use this other than altering something outside it's scope.

  • thanks so much, it helps a lot!

  • good job

  • Oh holy god, this shit is so confusing! This is the ONE part about C++ that I'm having trouble wrapping my brain around.

  • whats the point of a referance in a game?

  • @zwerty007 they are used so variables can bypass the rules of scope

  • @iam4eversmart88 Thanks, I was wondering this too, the book I have and the videos I've watched have not mentioned the practical applications of the feature. EMZ=]

  • I have at least two projects to do in C++, and I'm not good at pointers, at least there's help like this.

  • this guy teaches very well, although after i read a cuple of pages from C++ programming in easy steps, i actually think hes teaching is harder to understand for me but still not too hard :D.

  • @Blo0pTheZombies Where did you get a step by step guide?

  • @candychandelier Library lol.

  • gonna watch this tutorial soon. only thing that is ruin abit in my experiment with c++ atm is things get destroyed when it goes out of the scope..

  • Thank you! I spent the last half hour trying to decipher the difference between references and pointers.

  • i hate pointers...

  • Thanks so much for these videos, I'm taking c++ online and all of the reading can get tiring and confusing. This is very strait forward and easy for me to understand.

  • Yo Dawg so i herd you like pointers so we put an adress of an pointer in yo pointer so you can point at an pointer while you point at an int

    couldn't resist x)

  • @juliamd4 And you are officially he first person to make me laugh on Youtube

  • I was just curious, do all references and pointers have to be int variables, or does it change based on the type of variable they address?

  • @MysterySultan

    Pointer must be connect to what the point to for example:

    char a;

    a = 'b'

    char *c = &b

    int a = 50;

    int *i = &a;

  • Thank you.... you are better than my teacher!

  • I never understood pointers, thanks for the lessons, been programming c++ now for almost a year :P

  • I think there is a bug at 2:40, can someone please confirm?

    The problem is the last line says"

    cout << iAnotherInt

    yet the console says 10, which is actually the value of *ipPtrToInt and not iAnotherInt (which is 20)... can you please confirm otherwise I may be very confused...

  • @Taurusaud

    ipPtrToInt=&iInt

    & - give the address of the variable, not the value

    cout <<*ipPtrTpInt

    * - dereference to the value at the address

    so first line it is 10.

    next cout the same, but now ipPtrToInt points to the address of iAnotherint,so it is 20 this time.

    Bevore the last line, which you consider a bug, it is

    *ipPtrToInt=iInt;

    * - Dereference to the value of the address, the value of iAnotherint, and it is changed to the value of iInt, which is 10(just a simple variable)

  • i see now thanks for the help!

  • @Taurusaud 5 month old comment but maybe someone else has this question... In the first 2, you reset the address that ipPtrToInt is pointing... Like, Right now, I'm pointing at A, and now I'm pointing at B. What am I pointing at...

    In the third one, because of the different formatting, you aren't changing the address... you're changing what's AT that address... Now I'm pointing at A... Now I'm pointing at B... Now I'm changing what I'm pointing at to A. Since you were pointing at B.. B = A

  • @flamingfigures thanks for the answer mate - i ended up figuring it out eventually. coding right now actually, love this stuff!

  • @Taurusaud I figured as much ;) But you never know who has questions, Pointers always seem pretty obscure for a while

  • you will see when you start advanced stuff, for easy crap you build ofc you dont need it:)

  • Remember, they assigning a value to a pointer which, is pointing to iAnotherInt, for before statement, when is pointing , take the value, when his value is change, it assign value to the address is pointing to....my guess

  • Whats the point of References and Pointers?????? I can't find anything that needs them.

  • I have the same question. Why can't people just use the names of the variables themselves?

  • Comment removed

  • When you use classes in game programming it is very helpful as it lets you pass variables via address instead of name,(because of scope passing a name of a variablle is a bit harder).

    I am sure the same crops up in normal console programming aswell.

    Happy programming :-)

    from helpfullprogrammer.

  • @PCGamingHQ true true...

  • @PCGamingHQ

    Well... When you uploading a file to the internet what you will prefer?

    To upload it to many places and download from any location once or to upload it once and to use it many times with one address?

    I think that you will take the second option.

  • @eatMyRocket Thats an exelent explanation. I'll note that! (y)

  • @PCGamingHQ There's really no point in using refs and pointers at this level. It's only important for when you are using data structures. Then you can send a reference to the data structure as a function parameter and the function can use the structure. If you don't use a reference, you will send a copy of the structure to the function. But you don't want a copy, you just want one instance of the structure.

  • @PCGamingHQ to swap two variables with a function you need a pointer...

  • @PCGamingHQ Basically to access a variable by another function:

    void changeValue(int* iptr) { *iptr = 9;

    }

    int main() { int i = 3; changeValue(&i); std::cout << i << std::endl; // Output: 9 return 0;

    }

  • I really like your tutorials, I always wanted to learn C++!

  • the best C++ teacher !

  • At 2:12 can someone explain why the value of iAnotherInt is 10

  • Yes.

    ipPtrToInt = &iInt;

    Means the address of variable iInt is equal to ipPtrToInt.

    cout << *ipPtrToInt << endl;

    They use a dereferencing operator ( * ) to cancel the ampersand (&) and display the value of iInt which is 10.

  • @hellotherefriend00

    I believe it`s because before that line we have ipPtrToInt = &iAnotherInt; which makes the iAnotherInt equal to ipPtrToInt (in this case 20). After that, ipPtrToInt takes another value (10) and since ipPtrToInt equals iAnotherInt they now both contain 10 as their value. Confusing I know. If I`m wrong, someone please correct me.

  • Nice. But what are the primary purposes of pointers and references?

  • skyhr, pointers are primarily used to dynamically create arrays of any sizes

  • skyhr, pointers are primarily used to dynamically create an array of any size or dimension

  • Instead of physically moving data structures around in memory such as sorting or creating data trees, you can just move around the pointers to the data structures which is more efficient.

  • these tutorials are all quick, concise, and well thought out. the background music is amazing

  • I never really understood the difference between a reference and a pointer, but now i do! thanks a lot!!

    I also like the lovely background music =)

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