No lie - this is the best video that explains how pointers work that I have watched on youtube so far.
@ColinJoe229 жыл бұрын
I don't usually leave comments but you're a real Champ! Very easy to understand the difference between passing by value, pointer and reference. Cheers, mate!
@brianxavier8873 Жыл бұрын
im finally saved. i wish i came across this video 8 years ago. i cant describe how difficult it was understanding such a simple topic. yours is the simplest and easiest explanation to yndwrstand. thank you very much
@sparrowthesissy218610 жыл бұрын
This video is perfectly clear, thank you. I've been getting through C++ with a bunch of different tutorials online, but this is the first straightforward explanation of pointers and references I've found. Thank you, again.
@oleksijm4 жыл бұрын
It's the accent, mate! Hehe. Great video too.
@anilkj73079 жыл бұрын
Best video on youtube. In my last 8 yrs career, I was not this much clear about PBR, PBP, PBV. Now I am feeling very much confident about these concepts.
@alfredcalleja4507 жыл бұрын
Hi What's a Creel, I enjoyed your tutorial and got a lot out of it. I have read other explanations on how the Passing by Reference works and seen other videos, but yours is the best for explaining how the actual mechanism works. I like the way you get down to basics and explain the process from the ground up.
@MehmoodAhmedMooD4 жыл бұрын
Man you've made my life much easier by explaining the usage of & symbol in pass by reference context. I was always confused by it's common use of specifying the address. Thanks a ton :)
@SuperYouVIN12 жыл бұрын
You speak very clearly and straight forward. Good video.
@tava78010 жыл бұрын
Really enjoying your tutes! I'm not surprised at all that most of your videos have 0 dislikes. Thank you for your effort!
@bravheart959 жыл бұрын
Best c++ tutorials on youtube !! Thanks alot
@manfredpseudowengorz3 жыл бұрын
love those tiny bits of a fleeting confusion. they're the best. 16:16 So the two methods are exactly the same, they are pretty close, but they're not exaclty the same.
@BeefOffering10 жыл бұрын
This was a great lecture, it cleared up a lot of confusion for me. Thank you!
@jealr21229 жыл бұрын
Great video! Best explanation so far and good use of images.
@julianmahler23886 жыл бұрын
6:07 Before I looked at your code, I tried to do the same thing by myself with a function plusOne(int* n) that takes a pointer to an int and increases the number by one. When I used *n++ in the function body, it didn't work and I got a warning "value computed is not used". When I changed it to *n+=1, it worked perfectly. Does anybody know why this is? Isn't n++ exactly the same as n+=1?
@roykimor10 жыл бұрын
What's a Creel? 9:22 I'm pretty sure you meant to write points to an address 100 bytes higher (because it's a pointer to an int so 4 * 25)
@kcvinu5 жыл бұрын
Thanks for this video. Everything is crystal clear for even a newbie. Hope you can create more videos on the dark side of C++. :)
@d3duck10 жыл бұрын
Such a good tutorial... Never really got this but this makes me wonder why not.. Thanks a lot
@Jack-42427 жыл бұрын
I think a good advantage of references is, that to the caller the function looks as if normal parameters are passed and the fact, that they are passed by reference is decided by the callee and kind of hidden on the caller side. for example, if we have a Matrix class and a function add, the caller expects that he can add two matrices with this function and he does not really care that they are actually passed by reference for reducing the overhead of copying. as well, if we read into variables by using std::cin, the variables are passed by reference as well, but it looks much cleaner and the caller does not have to think about passing by pointer as you have to when using scanf.
@cyndy38738 жыл бұрын
Thank you so much! I was so confused what the difference of passing by reference and passing by pointer was!!
@NickSuda9 жыл бұрын
Thanks for making this video dude, I finally fucking get it. I thought of a music production analogy: Passing by Value is like making a non-destructive edit to a track, at the expense of managing an undo list until you've saved. Whereas Passing by Pointer and Reference are like making destructive edits directly to a track. lol
@alexisp415710 жыл бұрын
Thanks for explaining this concept so simply. Really helped!
@ChristopherJones169 жыл бұрын
Great video sir. I look forward to watching your assembly with c++ vids next. Btw the "star" as you refer to it is called an asterisk. To each his own tho right?
@fmmjqtft110 жыл бұрын
7:00 onwards. I think the usage of the same name, "a" for the pointer in function Add25, and for the integer in main is confusing. Add25's "*a" is not the address of main's "a". Actually Add25's "a" is the address (or "pointer to") main's "a", and Add25's "*a" is the same thing as main's "a". So the upper blue box labelled "*a" should really be labelled either "&a in main" or "a in Add25". Indeed, if you wrote "int a; int * a;" in main, then you would get errors, because "int * a" is declaring a variable "a" of type int * , but "a" has already been declared. Therefore I think it is better to write "int* a" instead of "int *a". "int *a" is horrible because it implicity declares variable "a", which is in fact the only variable it is declaring, and looks like it is declaring *a here, which it is not.
@julianmahler23886 жыл бұрын
Using the same name underlines that main's "a" and Add25's "a" can't possibly be the same variable as you can't declare two variables with the same name in the same scope.
@mozillaexplorer46919 жыл бұрын
im getting the error on a brand new clean custom pc. no operating system on it. trying to boot windows 10. first build. will start up. sometimes even asking me for the product key. Help?
@JM-fp3gf10 жыл бұрын
This tutorial is GRRRRRRRREAT!!
@ccbrucer11 жыл бұрын
I think if we neglect "*" before the a pointers, it is going to point to an address 100 byetes higher in RAM, for each int has 4 bytes. The pointer +1 will increase 4 bytes in RAM.
@CSryand2m9 жыл бұрын
I think it would have been a better tutorial if there was a visual representation of the heap as well, just to show how referencing is less expensive than copying; however, this was a great tutorial. Thank you!
@ChristopherJones169 жыл бұрын
I concur
@oleksijm4 жыл бұрын
Awesome vid once again!
@winkiversity10 жыл бұрын
best teacher !
@zoranjovanov85648 жыл бұрын
im still not deep into C++ but i cant change a struct values when i pass it by reference but it works when i pass by pointer. any help why how .. ?
@creelsmusic58148 жыл бұрын
That's pretty weird. What compiler are you on? I was using MS in the vids, I've just checked it now, and it seems to work fine.
@zoranjovanov85648 жыл бұрын
i use code block GCC/G++ compailer here is the function pretty long and messy but ull get it void switchtype(Type type,Player *player) { switch(type) { case Human :{(*player).lives=1;(*player).stamina=55;(*player).mana=120;(*player).armor=105;(*player).lvl=1;}break; case Elf :{(*player).lives=3;(*player).stamina=50;(*player).mana=150;(*player).armor=85; (*player).lvl=1;}break; case Ogre :{(*player).lives=6;(*player).stamina=35;(*player).mana=100;(*player).armor=110;(*player).lvl=1;}break; case Druid :{(*player).lives=9;(*player).stamina=50;(*player).mana=500;(*player).armor=30; (*player).lvl=1;}break; case Hunter:{(*player).lives=3;(*player).stamina=40;(*player).mana=30; (*player).armor=95; (*player).lvl=1.0;}break; } } when i pass by reference it gives random numbers
@creelsmusic58148 жыл бұрын
Hmmm, that's very interesting. The code looks fine, it looks like fun actually (you coding an RPG?)! Are you passing a player pointer by reference, or just an instance? If you are able, could you test the following code and let us know what it outputs? #include using namespace std; struct myStruct { int j; }; void SomeFunction(myStruct& k) { k.j = 100; } int main() { myStruct q; q.j = 0; SomeFunction(q); cout
@zoranjovanov85648 жыл бұрын
ya ya it printed 100 so i tried my code again and now its working. no idea why wasnt working before but seems just fine now. thanks for the effort man. nah im not coding RPG xd im just practicing pass by value ,pointer and reference on enums and structs.
@ChristopherJones169 жыл бұрын
Forgot, 11:47 you refer to the reference &a as a reference yet you wrote on the screen that's it's the "address of the variable a
@peihongzhong19958 жыл бұрын
Great! Very clear!
@riksharps197210 жыл бұрын
Nice explaination. Thanks!
@idobooks9096 жыл бұрын
11:11 pass by reference.
@yongamer9 жыл бұрын
Java do not have references or pointers. Is it because java wish to look simple?
@CzipperzIncorporated9 жыл бұрын
+Vegard Fjeldberg Java has pointers for objects and value types for numerics (int, float, etc). The problem with that is that you can't have a pointer or reference for numerics and can't have a value type for objects.
@ChristopherJones169 жыл бұрын
+chimera613 doesn't Java use like a virtual machine to compile or something of that nature? Is that why everything is a pointer?
@hongyionline6 жыл бұрын
great lecture!!
@s3anz212 жыл бұрын
Thank you! Very clear
@davey2k126 жыл бұрын
excellent needed this lesson
@ramymohammad86119 жыл бұрын
Thanks for making this clear
@Grinder-one10 жыл бұрын
Great...thanks very much.
@36goldfinger12 жыл бұрын
u speak nice .. great tutorial
@RemixEdits07 жыл бұрын
Use a s smart pointer, those are catastrophic prone.
@jurgi88812 жыл бұрын
useful comparison, thanks
@MH_Yip9 жыл бұрын
Good, It helps
@ilayasaravanan8 жыл бұрын
thanks, it was helpful.
@EvilRobin111 жыл бұрын
Thank you very much!
@lachampsfan11 жыл бұрын
well done!
@ChristopherJones169 жыл бұрын
Also something you should of pointed out over and over again Is that one can change the variable whereas the other cant change the variable.
@jetolbkk92966 жыл бұрын
big thanks...
@chandrakanthvenkatapuram194610 жыл бұрын
greattttttttttttttt
@nicholaskhoo897011 жыл бұрын
Thanks ! :D
@kritikarai51063 жыл бұрын
thank u
@sixpetrov11 жыл бұрын
tnx
@stigtheghost9 жыл бұрын
that was a good one :)
@RemixEdits07 жыл бұрын
But good example
@klaus95039 жыл бұрын
Hehehe it's funny how you pronounce "a". You say more "i" than "a" xD. "mine" hehe
@ChristopherJones169 жыл бұрын
Ahh you didn't even mention the real differences and advantages of these. That is that one you can change the variable and the other you can't. Sorry man I have to thumbs down this. You would watch other tutorials about pointers and references. They're a lot shorter vids and go over everything. I'll give you credit for the PowerPoint and stack illustration but come on man you really didn't clarify why one would use one over the other. Also you should've did a side by side comparison of the three to show the differences in code. This subject is usually the one that stumps noobs the most and deserves a well laid out tutorial. Noobs say this a great video but they don't know if the info you're teaching is even accurate.
@WhatsACreel9 жыл бұрын
+christopher jones Thumbs down if you must! I salute your honesty, and if I ever make another vid on the topic, I'll try to remember what you want to hear.
@ChristopherJones169 жыл бұрын
+What's a Creel? Haha I must apologize for my super critical comments which I was probably wrong about. I just got out of the hospital and on medication so I'm easily agitated and probably will have a better time watching after my recovery and not under the influence. The docs should put a new note on the bottle "do not operate heavy machinery nor program on c++ while using this medication" Glad you're a good sport. I think I just need to get used to the longer tutorial vids. I'm more used to vids being shorter with the info being broken up and scattered out more into separate videos so it's not as much info to take in all at once. Anyway im a subscriber and you're doing a damn good job cheers.
@genoyostevon100010018 жыл бұрын
compared to C yeah... you shouldn't program in c++ on medication ... put this in your compiler ...your going to have to space it out.... #include #include #include #include #include #include #include #include using namespace std; char* removePunct(char* word); char reverse(char *); bool palindrome(char[]); int main() { int length; string bob; const int LEN = 64; char word[LEN], *x, *y; coutword; length = strlen(word); cout
@ChristopherJones168 жыл бұрын
bob dole thanks ill give it a go. Im new to these "tokens" are however. Gotta love C++ always something new to learn everyday.
@alfredcalleja4507 жыл бұрын
Christopher, why don't you delete this stupid comment!