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'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
@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"
@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*
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.
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
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.
@TaylorHolmes check this guys video out "C++ Tutorial (42 updated 1) - Absolute n00b spoonfeed" This video along with video 43, 44, and 45 will explain it so it makes perfect since. He doesn't start talking about pointers until about midway throug video 43 but you will want to start off with video 42 so you can get a perfect understanding of whats going on.
@TaylorHolmes check this guys video out "C++ Tutorial (42 updated 1) - Absolute n00b spoonfeed" This video along with video 43, 44, and 45 will explain it so it makes perfect since. He doesn't start talking about pointers until about midway throug video 43 but you will want to start off with video 42 so you can get a perfect understanding of whats going on.
@TaylorHolmes check this guys video out "C++ Tutorial (42 updated 1) - Absolute n00b spoonfeed" This video along with video 43, 44, and 45 will explain it so it makes perfect since. He doesn't start talking about pointers until about midway throug video 43 but you will want to start off with video 42 so you can get a perfect understanding of whats going on.
@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=]
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.
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.
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 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
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
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.
@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.
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.
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.
Thank you for this, friend.
BlckSbthMan 17 hours ago
ur videos r so awesome. hope u make more. Great job!
formchoi2190 3 days ago
WTH ? (What The Heck ?)
this is the best tutorial in the youtube!!
2kingovidiul 1 week ago
Why should we use a Reference and Pointer?
Dinozzo98 3 weeks ago in playlist C++ Beginner Tutorials
Great video but you sound like napoleon dynamite :p
alililiff 1 month ago
Pointer pointing to a pointer?
pointerception.
rosstripi 4 months ago 5
Comment removed
AIDSMcGuff 5 months ago in playlist C++ Beginner Tutorials
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...
partoftheherd 6 months ago 7
I'm a fan, thanks for the help
DIEaHEROdotNET 7 months ago
love the videos, but the intro music is so annoying!
lullabynasdaq 7 months ago
It's easy for me to understand,and it's clear!
謝謝製作這部影片的老師^ ^
chulove522 7 months ago
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
dmaster911 9 months ago
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 9 months ago
@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 9 months ago
@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 9 months ago
@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*
Slynas 9 months ago
@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;
drakion1989 7 months ago
@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".
drakion1989 7 months ago
@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,
drakion1989 7 months ago
@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 7 months ago
@drakion1989 And yet you have spare characters free to complain about the lack of characters. I think I detect a hint of irony.
LankyLuke97 5 months ago
Comment removed
Slynas 9 months ago
Comment removed
Slynas 9 months ago
Comment removed
Slynas 9 months ago
mew2king faved this so i clicked on this lol
jasonhan8733 9 months ago
When should I use pointers over references (and vice versa)? Thanks.
Hassan99999 9 months ago
Hey, is it possible to download all your episodes through one file?
Or have you only uploaded them on Youtube?
Thetimpson 9 months ago
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 10 months ago
@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
dojOdRiFTeR 10 months ago
does c++ reference and pointer are similar to VB byref and byval ?
bojanglesme 10 months ago
@bojanglesme
c++ pointer can also be point to other ,reference cant so i think the answer is no.
4Got10Shadow 10 months ago
If we have pointers, then why do we need to use references in the first place?
mediantiba 11 months ago
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.
davemedway 1 year ago
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.
666Makkura666 1 year ago
thanks so much, it helps a lot!
lifeles 1 year ago
good job
JEJOEMS 1 year ago
This has been flagged as spam show
@TaylorHolmes check this guys video out "C++ Tutorial (42 updated 1) - Absolute n00b spoonfeed" This video along with video 43, 44, and 45 will explain it so it makes perfect since. He doesn't start talking about pointers until about midway throug video 43 but you will want to start off with video 42 so you can get a perfect understanding of whats going on.
iam4eversmart88 1 year ago
Oh holy god, this shit is so confusing! This is the ONE part about C++ that I'm having trouble wrapping my brain around.
TaylorHolmes 1 year ago
This has been flagged as spam show
@TaylorHolmes check this guys video out "C++ Tutorial (42 updated 1) - Absolute n00b spoonfeed" This video along with video 43, 44, and 45 will explain it so it makes perfect since. He doesn't start talking about pointers until about midway throug video 43 but you will want to start off with video 42 so you can get a perfect understanding of whats going on.
iam4eversmart88 1 year ago
This has been flagged as spam show
@TaylorHolmes check this guys video out "C++ Tutorial (42 updated 1) - Absolute n00b spoonfeed" This video along with video 43, 44, and 45 will explain it so it makes perfect since. He doesn't start talking about pointers until about midway throug video 43 but you will want to start off with video 42 so you can get a perfect understanding of whats going on.
iam4eversmart88 1 year ago
whats the point of a referance in a game?
zwerty007 1 year ago
@zwerty007 they are used so variables can bypass the rules of scope
iam4eversmart88 1 year ago
@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=]
GeekTeen 1 year ago
I have at least two projects to do in C++, and I'm not good at pointers, at least there's help like this.
Remerai 1 year ago
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 1 year ago
@Blo0pTheZombies Where did you get a step by step guide?
candychandelier 1 year ago
@candychandelier Library lol.
Blo0pTheZombies 1 year ago
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..
Necry3d 1 year ago
Thank you! I spent the last half hour trying to decipher the difference between references and pointers.
scorpion8588 1 year ago 5
i hate pointers...
Decklanx 1 year ago
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.
aikiuke 1 year ago 26
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 1 year ago
@juliamd4 And you are officially he first person to make me laugh on Youtube
MrFarklefreak 1 year ago
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 1 year ago
@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;
eatMyRocket 1 year ago
Thank you.... you are better than my teacher!
lisa0087 1 year ago
I never understood pointers, thanks for the lessons, been programming c++ now for almost a year :P
boisei0 1 year ago
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 1 year ago
@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)
Qualia 1 year ago
i see now thanks for the help!
Taurusaud 1 year ago
@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 1 year ago
@flamingfigures thanks for the answer mate - i ended up figuring it out eventually. coding right now actually, love this stuff!
Taurusaud 1 year ago
@Taurusaud I figured as much ;) But you never know who has questions, Pointers always seem pretty obscure for a while
flamingfigures 1 year ago
you will see when you start advanced stuff, for easy crap you build ofc you dont need it:)
themewz 2 years ago
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
omahdezavalos 2 years ago
Whats the point of References and Pointers?????? I can't find anything that needs them.
PCGamingHQ 2 years ago 5
I have the same question. Why can't people just use the names of the variables themselves?
caesiume 2 years ago 2
Comment removed
EigenaardigKnaapje 2 years ago
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.
helpfullprogrammer 1 year ago
@PCGamingHQ true true...
Biohazard000Labs 1 year ago
@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 1 year ago
@eatMyRocket Thats an exelent explanation. I'll note that! (y)
666Makkura666 1 year ago
@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.
howitzer24 1 year ago
@PCGamingHQ to swap two variables with a function you need a pointer...
JamesTR4 1 year ago
@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;
}
NESQUiK87 1 year ago
I really like your tutorials, I always wanted to learn C++!
GoodLegoInventions 2 years ago
the best C++ teacher !
allmusic85 2 years ago 70
At 2:12 can someone explain why the value of iAnotherInt is 10
hellotherefriend00 2 years ago
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.
dynamatlancer 2 years ago
@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.
djsotos 2 years ago
Nice. But what are the primary purposes of pointers and references?
skyhr 2 years ago
skyhr, pointers are primarily used to dynamically create arrays of any sizes
MrTakeAshot1 2 years ago
skyhr, pointers are primarily used to dynamically create an array of any size or dimension
MrTakeAshot1 2 years ago
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.
CorporationsSuck 2 years ago
these tutorials are all quick, concise, and well thought out. the background music is amazing
hurstshifter 2 years ago 2
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 =)
iMurph01 2 years ago