It's funny how my professor tried to describe how this works in a 2 hour lecture to no avail, and I got it immediately from your videos in about 20 minutes. Good job man :) thank you.
@geekybench7 жыл бұрын
Mine has been teacher for almost a semester
@jayblankenship15536 жыл бұрын
thats how professors are they are more focused on sounding better then you while this guy cuts the shit and tells it to you straight.
@darrenfrancis81262 жыл бұрын
for me this is better because i can stop on the section I'm confused about and until i understand ill move on. My professor is face paced but I use her as an outline of what's important to study since i can't sit there and ask questions about everything during the lecture.
@antiHUMANDesigns9 жыл бұрын
This is a bit wrong. Pass by reference uses references, not pointers. Pass by *address* uses pointers. Reference and address is not the same thing. It's an important distinction because pass by reference is handled differently when calling the function. Pass by reference function looks like this: passByReference(int &x); // reference, *not* pointer. While pass by *address* looks like this: passByAddress(int *x); // pointer The important difference here is that passByReference is used (called) the same way as passByValue, while a passByAddress requires that you specify an address or a pointer as the argument. That is, you need to send a pointer/address, or you need to put an ampersand (&) in front of your variable to denote it's address rather than it's value.
@GreenPlimpie9 жыл бұрын
antiHUMANDesigns Thank you! I was starting to doubt myself there when I couldn't find any comments pointing out the mistakes here. He got reference and address completely confused and he's probably gonna confuse lots of people :/
@antiHUMANDesigns9 жыл бұрын
Randa Moustafa Yeah, it's a shame.
@antiHUMANDesigns9 жыл бұрын
Kim Nguyen Yes, a reference is an alias. Change the value of the alias/reference, and you change the original value aswell, because they're the same thing. References simply allow you to extend the scope of something, instead of having to copy it. As for "swapping" references, you can't, but you can still swap "by value". If you send x and y by reference into a "swap" function, the funtion will store x in a temporary variable, then copy y to x and then copy the temp to y. So it's a swap by value. If you send a "reference to a pointer" into a function, then you can swap the pointers without having to copy the data the pointers are pointing to. Just swap the addresses instead. Not sure you understand the concept of "pointer-to-pointer" or "reference-to-pointer". Tell me if it doesn't makes sense to you. I hope I understood your question correctly.
@mishoaleksidze78209 жыл бұрын
+antiHUMANDesigns Thanks for writing this comments, now it's clear...
@antiHUMANDesigns9 жыл бұрын
***** A reference is just an alias. Say you create an object or variable and call it "a". Then you create a reference to that object or variable, and the same object/variable simply has 2 different names. Lets say the reference is called "b". So no matter if you use "a" or "b" it will be exactly the same thing. int a; int &b = a; // reference to "a" Now, in every way, "a" is the *same* as "b", and they can be used the exact same way with the exact same result. They are the same. A pointer, however, is different because once you've used it to point to something, you can change so that it points to something else, and you can also change it so that it points to *nothing*. References can never change what they refer to, once they've been created, and must always refer to something. And pointers use different semantics, so they kind of "look" more different than they are, in a sense. So what's the point of references? They allow you to extend the scope of something, that's their one and only purpose, unless oy usimply use them as aliases, whcih is kind of pointless. This means that when a variable would normally not be in a specific scope, you can make it be in that scope by using a reference. For example: int a; myFunction(a); Inside that function, "a" doesn't exist, it's not its scope. But sending a reference to the function extends the scope of "a" so that it also exists inside the function. And a function that returns a reference allows you to extend the scope of a temporary variable/object from inside the function, so that it remains outside of the function, where it would normally be automatically deleted. int& myfunction() { int a; return a; } Even though "int a" is a temporary variable that would be automatically deleted when the function ends, because a reference to it is returned by the function, it won't be autoamtically deleted. So it's scope has been extended to the scope where the function was called. Some people may tell you that you can't do that, but you can. Perhaps you couldn't do it in some older version of C++, I don't know.
@skippyscourge18112 жыл бұрын
Bucky, just wanted to say, you are an extremely good teacher, i was having a hard time grasping classes and pointers in c++ until you put them into plain simple english, I'm kinda new to c++, but I've been programming in various other languages since the late 80s, and never have i seen or experienced such amazing teaching.
@advaitharmy8 жыл бұрын
For people who are having confusion over *x = 66. Let me explain, When a value is assigned to *x in any places other than pointer declaration place(i.e int *x), it is called as dereferencing the pointer. In simple words what *x=66 does is assign a value of 66 at the address pointed by the pointer.
@gowthamprabhu1227 жыл бұрын
oh that makes it much clear. But what about the declaration place? To make x point to sandy do we declare int *x= sandy or int *x= &sandy ?
@advaitharmy7 жыл бұрын
It depends on what sandy is here. Sandy should be a integer value here, as x is a pointer of type integer. So int*x =&sandy is correct where x has address of sandy. If sandy is an array of characters you can just write string*x = sandy, where & is not required while assigning the array address.
@nickbossbg56367 жыл бұрын
Here i will try to explain: Dereferencing a pointer means to get the value of the address to which the pointer is pointing. int betty = 13; // defining a variable called betty with value 13 int *x; // declaring a pointer x, here int *x means that we are declaring int pointer with name x x = &betty; // here we are making our pointer x to points to the memory address of the variable betty *x = 66; // here we are dereferencing the pointer and assigning value 66 at the address to which our pointer x is pointing cout
@Happydayz-20256 жыл бұрын
NickBossBG In the pass by reference function, instead of passing a copy of the value contained in that variable, the programmer passes the address of the variable which allows the user access to modify the value at that address.
@warkid9996 жыл бұрын
this cleared all my doubt thanks buddy
@jake26636 жыл бұрын
These tutorials are from 2011 over 7 years old and they are still so very helpful bucky I know you probably don't read comments anymore but thank you so much you've helped me through so much and taught me so much and not just helping me with my C++ homework.
@georgekougioumtzoglou53448 жыл бұрын
I love your tutorials... I am sitting and watching them although I know C++!!! I think you are a have a great talent in teaching.
@TheeChrist-Talks4 жыл бұрын
This is awesome
@good-tn9sr3 жыл бұрын
@@TheeChrist-Talks woowowwowowowoow very cool
@strangecuriousandunusual7 жыл бұрын
#include #include #include #include #include using namespace std; void passByValue(int x); void passByReference(int &x); void passByAddress(int *x); int main(){ int salley = 11; int betty = 12; int ella = 13; cout
@ouihui7 жыл бұрын
Thanks for this example! Quick question, when you pass by value, how do we get the value 99 to be returned (besides using pbr or pba) so that we can cout 99 instead of 11?
@alexandrucosmin906 жыл бұрын
can you explain me how they are conected? X -> int bella, then X -> int betty X -> int Ella? please!
@gamepurpose6 жыл бұрын
so what is the different between the 2nd and the 3rd example? any benefit doing one not the other?
@GTBBwastaken6 жыл бұрын
@@ouihui Excuse me for being 1 year late, lol. I will use part of the above example to help you: int passByValue(int x){ x = 99; return x; } in main you need to cout
@jorgehabib86615 жыл бұрын
fire
@reefsami80106 жыл бұрын
So that’s my second semester in programming.. and still when ever I get stuck in some things and I can’t figure them out I immediately think “ oh I think I need to go on KZbin and see what bucky said about it” then I understand it instantly.. you have an incredible and effective way of delivering information .. you have a gift man .. Arab people love you 💚💚💚💚
@PravatKTimsina3 жыл бұрын
I don't know how far did you reach by now. You commented three years ago. I'd be more than happy if you could share your experience. I am a beginner it can be a motivation. 4/29/2021
@laqras2 жыл бұрын
@@PravatKTimsina what happend now? are you now good i coding?
@Bugazia10 жыл бұрын
reviewing C++ as i havn't been around it for around 11 months or so, and you're making it easier for me, thanks Bucky!
@seto71310 жыл бұрын
I swear, you're truly a genius. I go to lectures staring at my Professor for three hours as he goes on and on about this shit and you cleared it all up in less than 10 minutes. Thanks :D
@juzzy1k11 жыл бұрын
dude you are so helpful. this is so much better and helpful then my class im taking!
@sidrockx9511 жыл бұрын
the best part is : he makes those videos in under 8 minutes. most of 'em. And its so easy to grasp all the things he says. exceptional teaching! :)
@GuyBaker55510 жыл бұрын
Very good Bucky, I am retraining from C to C++ so a lot I can skip through but the explanations of C++ specific features, in small easy to digest steps is fantastic!
@PeterLakeTV12 жыл бұрын
Bucky, you have such a magical way of making anyone understand things. We all can't thank you enough for your awesome free educational videos. I swear, you should move to Canada and be my teacher :P
@AlexTimification11 жыл бұрын
Thanks Bucky, for your tutorials. I'm learning c++ after java and c#. As a Java-programmer on an amateur level, I would say, the pointer feature is by far the most noticable advantage of c++ over java. And the passByReference feature is just amazing in C++. TO make it in Java, you need to write more code :D
@joshp34466 жыл бұрын
honest to God over the past few days i have scoured the internet i have searched what feels like Dozens of Articles, Videos, Forums, Etc. and only about 2 or 3 People that i found (And i had to DIG for these videos btw) only like 2 or 3 of you explain THE CRUCIAL DETAIL THAT POINTERS (AND NOT JUST DE-REFERENCEING A POINTER, TO PULL THE VALUE OUT) STORE THE VALUE OF THE MEMORY ADDRESS AND THAT IT CAN BE CHANGED, ITS NOT JUST THE ADDRESS THAT GETS STORED THE VALUE TOO! NO ONE BOTHERS TO EXPLAIN THIS DETAIL! AND YOU DID! THANK YOU! I UNDERSTAND THIS SO MUCH F*CKING MORE NOW BECAUSE YOU ARE ACTUALLY INTELLIGENT! THANK YOU SO MUCH, YOU HAVE EXCELLENT VIDEOS, AND YOU HAVE EARNED YOURSELF A SUBSCRIBER. THANKS AGAIN!
@fusiondew5 жыл бұрын
I've been trying to learn OpenGL and I couldn't wrap my head around why you would go through the trouble of making a pointer and passing that instead of just the variable but it makes perfect sense now. Thank you bro!
@HugoIetsGaming9 жыл бұрын
I am beginning to understand pointers, Bucky you are a hero!
@RobertGuilman3 жыл бұрын
Thankkkkkk yoooooooouuuuuuu, i really struggled with this. Your explanation is the clearest even tough it was made 9 years ago
@BuckFangs9 жыл бұрын
Thank you bucky, extremely grateful for the tutorials and the fact that they are quick lessons.
@Phoenix70011 жыл бұрын
Man you explain these topics sooo much better than my uni textbook, in 8 minutes I understand pointers compared to weeks being confused by it
@ElderGod411 жыл бұрын
There's a diff between coders and programers :P
@MrFavorite0111 жыл бұрын
***** Sorry, I'm a bit dimwitted to what you said. Can you tell me the difference? I'm can only guess by what you mean.
@dibbiepk11 жыл бұрын
Sun E. Coders, are people who can understand the code, and write code, but dont exactly have any idea on what there doing. There advanced in logically THINKING and UNDERSTANDING, then ACTION, and PHYSICAL CONSTRUCTION. Programmers are people who can write code, debug (test and edit, and remove errors and idiot-proof it) code. They have a general understanding on the code,they know what all the functions are at least, but they also have a idea on what their doing, and why they did it. They can explain it, and remake it if needed. And they can (normally) do it in many different ways, or at least know many different ways it can also be done. Bucky is a programmer. He is experienced. When he was starting out learning to program, he might be considered a coder. He was not experienced. He may of understood what a function did. But had no idea how to re-produce the function. In any programming production, a coder may be just as useful as a programmer. If that makes sense... If not, check this out: workfunc.com/differences-between-programmers-and-coders/ Might explain it better.
@shizyninjarocks8 жыл бұрын
Super cool! Thx, Bucky, you've saved my ass so many times.
@JRichard1128 жыл бұрын
Know this was sometime ago, Bucky, but this was really comprehensive. Learned a lot from it.
@lukecharles38805 жыл бұрын
"i mean come on guys, enough with the E's." Had me in stitches xD
@kaibest4 жыл бұрын
so many years... and now i understood. thanks so much man!
@kaoknight12 жыл бұрын
Thanks you for the tutorials. You are way better than all of my professors.
@zeMasterRuseman11 жыл бұрын
Best explanation of pointers I've seen. This pointer confusion was scaring me away from C++, now I might go and learn it.
@informativecontent47787 жыл бұрын
if anybody wants to run Buckey's code @7:05 here: #include #include using namespace std; void pbv(int c); void pbr(int *c); int main(){ int a=20,b=30; pbv(a); pbr(&b); cout
@d_disjointed_d13 жыл бұрын
Man, thank you very much! Only because of you and your tutorials I'm finally understand what pointers about! You are more than just awesome, you are incredible person and teacher! Sorry for bad English.
@ujjwalmainali392711 жыл бұрын
don't know why but i learn fast with your explanation. Thank u Bucky.
@lloydydydy12 жыл бұрын
You're the only one who made me understand the reason to use pointers. Thank You!
@shinemooon12 жыл бұрын
I love you Bucky. I hate pointers before, but now, thanks to you, I understand them very clear.
@18vallancel11 жыл бұрын
In all my CompSci classes my lectuerer never once touched a computer- 100% death by powerpoint. Surprisingly I didn't learn anything. But you, Bucky, are something else :D
@silakanveli6 жыл бұрын
Thanks for this video. Probably the best video about why to use pointers. Bravo
@PrasannDatta12 жыл бұрын
thanks bucky you saved me from failing in exam , you are just amazing buddy GOD BLESS YOU
@Pwncakes196613 жыл бұрын
As soon as you explained that it gives functions direct access to a variable I saw about 1000 game programming uses. =D
@ubuntujax500811 жыл бұрын
dude i love your c++ tutorials. You crack me up and help me learn!
@toxickremedy10 жыл бұрын
Thnx a lot. This was very clear. It took me 4 times to watch to understand it, but this was great.
@dmaster20ify7 жыл бұрын
Thanks man. Thanks to your videos, Only now do I really understand what a pointers. Metaphorically, a pointer is like a parasite. It doesn't own any address in memory and has to leech onto another variable of the same type. You don't use the * pointer operator when you want to change the address of the pointer. But you use the * pointer operator to change the value stored at the address and also to declared the pointer in the first place. A very important rule is you cannot assign a value to the pointer variable when it is newly created. This is because as I said; the pointer variable is a parasite because it isn't born with a memory address. Or to put it another way, the pointer variable is a homeless man! Since it isn't given a place in memory, it simple cannot store any value in memory. Memory is where all the values of your compiled program is stored until you programmed it to write the values to your harddrive. So the pointer is born without any address and cannot store any value. But once you point the pointer to the address of a variable, it basically hijacks the address of the variable. Now it is able to store values. When storing values to the pointer variable's name, you must include the * pointer operator. Only one value can be stored to any address in memory, so giving the pointer variable a value will simultaneously change the value of the original variable. Reversely, changing the value of the original variable also changes the value of the pointer variable. Funnily, the pointer variable can decide to stop being a pest to one variable, but then it has to be a pest to another variable. To change the address of a pointer variable you say pointer variable = address of next variable. Just ensure that you don't use the *pointer operator. In fact I really think that sign means "value of pointer". Check out the following example for a better illustration. You can also compile this program, because I tediously checked it for errors, run it and you will get a very good illustration of how the pointer works in C++. _______________________________________________________________________________ #include using namespace std; // using std namespace is cool because my code is short /// Declare Global Variables int a = 10; int b = 20; int *pnt; // saying "*pnt = 100" is big mistake because "pnt" has no address now /// Main Function int main () { { cout
@cmcdonough211 жыл бұрын
Seriously your vids have really taught me a lot. Thanks for taking the time to make them.
@decall6 жыл бұрын
I have watched your video 4 times and now I finally got it :) thank you..
@linkinaryan7 жыл бұрын
Bucky: (types) int betty = 13; int sandy = 13; Me: *sigh* i see..bucky u still haven't gotten over ur break-ups....
@Fireblades21212 жыл бұрын
im just goin out on a whim here, but i beleive you learned more from bucky because your not limited in how fast you can learn.
@kkkkkkkkkk19113 жыл бұрын
the reason, why the code below works is that when we use pointer (which is actually the address of variable , i.e. *pointerA=&a; (here 'a' is any variable).) the parameters of the function is an address, so while calling it we need to pass an address, this is what Bucky did in the tutorial. similarly when we use '&', the parameter(s) is an address [just like the case in pointers] but while calling the function we do not have to pass the pointer of the variable, we just pass the variable itself
@SandipGairhe6 жыл бұрын
I just came to know after all those above tutorial that you are genius. I know genius pretty well.
@FatMorton6 жыл бұрын
A good way to remember this is by imagining that the argument is changed to int x = betty, meaning that if you change x, it will not change betty. By saying int* x = &sandy, you are saying that x is pointing to where the original sandy is stored, allowing you to change sandy by changing the contents of where x is pointing to. If you don't get it, look below. since in _"passByValue(int x)"_ "x" is a normal variable, _"passByValue(betty)"_ is like saying _"(int x = betty)"_ so f you change x, it won't change betty. but since in _"passByReference(int* x)"_ "x" is a pointer, _"passByReference(sandy)"_ is like saying _"(int* x = &sandy)"_ so if you change *x (the contents of x), it will change the value of sandy.
@kkkkkkkkkk19113 жыл бұрын
Passing by reference can also be done by not using pointers, in that case we pass the variables in our function as: void passByReference(int &x){ x=66; } this would actually set the value of the variable passed as 66. now when we call it in our main function : ... void passByReference(int &x); int main(){ int a=10; // any variable a passByReference(a); // here we passed the variable 'a' and not the pointer a cout
@skippycavanaugh31486 жыл бұрын
I ain’t gay, but I love u bro. My CS exam may go well because of ur short yet amazing videos.
@EnterANameReal13 жыл бұрын
@chiste916 I think some comments before answered this. Normal passing by reference uses the ampersand(&). But this is pass by reference WITH pointers. So if you pass a pointer, you have to dereference it with the asterisk (*). A pointer contains a memory address, you derefence the memory address to access the data it's pointing to.
@CSryand2m9 жыл бұрын
Passing by reference to C++ is like gravity is to Interstellar. Pass by reference (gravity) is a way of communicating with the heap (the past), by transcending the dimensions of the computer (space time) in which it was previously bounded by the call-stack (the present). Nerds unite!
@thegamingruler199612 жыл бұрын
this is basically ByRef and ByVal in Visual Basic but now I understand how ByRef works from inside you learn so many neat things switching from high level language to a low level one :)
@TheHTMLCode12 жыл бұрын
yes - when you think about it - passByValue(betty); has a value of 13 so the output would be 13, int x is not called because it is not required to, as value Betty is the input value. in the case of sandy = 13, she is obviosly reset to the value of 66 because passByReference(&sandy); assigns her with the pointers memory value = 66 Hope this makes sense :)
@hariscengic73028 жыл бұрын
I laughed my ass off at the end "Aaaanyways, moving on " hahahahah .... i wanted to hear the milkshake story
@metax7311 жыл бұрын
YES, I will dream of this tonight. Complete Bliss.
@austinkarunyaaccount99076 жыл бұрын
I missed watching your tutorials Bucky :)
@Jns30006 жыл бұрын
hey please do more videos your videos really help, way better than my professor's lectures. Thank you
@Jazz_Otter3 жыл бұрын
Oh. My. God. Not one professor I've had has explained the purpose of and how to use pointers as clearly as you have in this video 😂 Thank you so much!
@tejaskadam18896 жыл бұрын
sorry to say that but here you made mistake in interepretation if this is the case that we should call it as pass by reference,then what is the case for pass by adress using pointers,here you have shown pass by adress using pointers;
@w0mblemania13 жыл бұрын
@Anddosdd Because it's much more important at this stage to show people how pointers work. C++ References tend to obscure and confuse the role of pointers for newbies. Only once programmers fully understand pointers, can can use References properly, including knowing when not to use them.
@tedmutesick57276 жыл бұрын
Now that's some Quality Tutorial and Teacher! Thankz Bucky!!!!
@ahmermirza8 жыл бұрын
Thank you so much!!!! I finally understand pass by value and pass by reference :))
@asm32826 жыл бұрын
@6:55 "x" is a variable with the same "type" as "Betty" not "value". "Betty" and "x" have the same type of "int" but different value of 13 and 99 respectively.
@hoxdl213110 жыл бұрын
Hey btw, you are not passing by reference, you are passing by pointer ( just something to keep in mind).
@nayanparmar98714 жыл бұрын
Just check again the whole code and watch again the whole video. In video we are passing by reference with pointers you know so it's correct . Passing by reference with pointers na that's why you seems like that
@Nick-lx4fo4 жыл бұрын
@@nayanparmar9871 Technically it's not a reference, he's passing a value using a pointer, a pointer is not a reference, a reference is denoted by an &. He'd want to be using that instead of pointers favorably.
@christianamado58603 жыл бұрын
This also works... #include using namespace std; void passByValue (int x); void passByReference( int &x); int main() { int num1{13}, num2{13}; passByValue(num1); passByReference(num2); cout
@heisenberg79453 жыл бұрын
yeH This worked for me but one from vid wont work it gives error
@longfeizhang45108 жыл бұрын
Thanks Bucky! I have benefited a lot from your videos.
@FamilyChannel7-377 жыл бұрын
keep it up. I love your presentation. My professor is using your tutorials in a class. You may update the tutorials from comments and suggestions. Again thanks a lot. Blessings!!!!
@Rigardoful13 жыл бұрын
@uccoskun He'll probably explain later on ... Arrays are pointers. When you create it, it allocates enough memory for n elements. Every element takes a k number of bytes, which your pc knows and they're all in one block of memory, the one after the other. So supposing the address is number M, to access element 5 it says, I'll go to address M+5*k. So when passing an array, you're passing a pointer to the first position.(if not mistaken, array[] gives you a pointer to the block of memory) I
@956Irvin3 жыл бұрын
You are a literal God send my friend. Thank you!!!
@Jack-424213 жыл бұрын
your tutorials are very helpful you exlain everything very well
@UAslak10 жыл бұрын
This is amazing. I had a C course that introduced pointers as something difficult and dangerous, but I literally understood it the first time you explained it. One question though. You said something like, it's useful to give functions direct access to variables so the computer doesn't have to make a million copies of that variable. Does that mean that it is common practise ALWAYS (or in most cases) to give functions direct access in order to save computing power?
@LurkrulDoesThings10 жыл бұрын
I would think that this would only make a difference if you were working with some large amounts of data, or if the value had to change permanently (although you could also give it a return and set it equal to that)
@bayleymakloski5326 жыл бұрын
If you know for a fact that you're going to need the original copy of that variable at some other point along the line, don't pass by reference. You'll end up using more of the memory of the computer, but if you are dealing with a small amount of data, even say 1,000 entries, you'll probably be fine. In practice, the more concise your variables are the better.
@kkkkkkkkkk19113 жыл бұрын
[contd. from my last post] because you have '&' which explicitly refers to the address of the variable. Also in this case we do not need to use the dereference operator * , in order to alter the value of the variable passed. i.e. instead of *x=66, we can do x=66. Hence it means the same thing. Just a slight change in concept.
@TheTurmAx11 жыл бұрын
You could also pass reference like: int main() { int x = 0; modValue(x); cout
@pietrocasalone88156 жыл бұрын
like most people said, this is the very first not totally clear tutorial of c++ you did; the only mystake is that you didn't introduce the deference operator making us to panic. BTW one error in 38 tutorial doesn't make these tutorials less awesome
@SirRobbStarkGamin9 жыл бұрын
/* Example of Pass By Value and Pass By Reference, PBR is when the varible location and value is passed making it possible for a outside function to change the varible inside the int main, because PASS BY REFERENCE increases it's scope */ #include using namespace std; //This Function the value is passed an reference, where it can change the varible inside the int main void PassByReference(int& val){ val += 10; } //This Function ONLY the value is being passed, so the int main varible cannot be changed void PassByValue(int val){ val += 5; } int main(){ int num1 = 5; int num2 = 5; PassByReference(num1); PassByValue(num2); cout
@josuegialis81468 жыл бұрын
ayeee! lmao took a break from CIS homework to get a milkshake from McD's and came back to finish this tutorial lol
@zeeshiscanning12 жыл бұрын
youtube should have a button "like to the power of like" for bucky's videos :)
@bayleymakloski5326 жыл бұрын
If you're watching today, this is not actually pass by reference, this is instead pass by address (pointer). To pass by reference, just simply put the '&' operator before your parameter. Then in the body of your function you can simply use the variable without having to put a '*' before the variable.
@donaldcsorny14877 жыл бұрын
Bucky your a wizard! Another great tutorial.
@Sunsetrider9211 жыл бұрын
I finally fucking understand pointers. GAH, you're good, thank you.
@balanar4o6 жыл бұрын
excellent explanation. Thank you for helping me understand.
@luissantiago79787 жыл бұрын
"There are too many e's in reference" 😂😂
@vibol0312 жыл бұрын
a pointer to a pointer to a pointer to a pointer...and the circular list continues
@cameronaldridge54056 жыл бұрын
Thank you I finally get the reason you’d use this
@leafmountain8 жыл бұрын
Finally I understand WHY pointers are used! Thank you!
@DJ1172611 жыл бұрын
That stills creates another variable, the value of which is set to betty. It still changes betty but the whole point is to use less memory so your programs don't bog computers down with a bunch of variables that really aren't needed.
@pip3s2011 жыл бұрын
First Thanks for this tutorial I'm learning c++ because I need understand some codes, I'm a Fortran Programmer and I do not understand what the pointer is....so, for example, we can do the same of passByReference() by doing this: int pass(int x){ x=66 return x; } and then in the main sandy=pass(sandy) Soy I need to know, when is recommendable to use pointers?? THANKS
@olestrohm11 жыл бұрын
the passByReference method puts less stress on your computer than the passByValue method or the method you made. hope you understand this :)
@quataoxann8311 жыл бұрын
Reason why you use pass by reference is you can return more than one value. while for the pass by value, you can ONLY return ONE value at a time.
@alvarobusquets2 жыл бұрын
Watching your video night to exam
@ifyouwereasoup11 жыл бұрын
pretty sure that what you called passByReference is actually a passed by pointer function, since you had to dereference it and could go into arithmetics.. to be a passed by reference funtion you would use the actual int &x instead of the pointer to the adress inside the function.. this way you wouldnt have to dereference it too
@sweepingtime2 жыл бұрын
Milkshake throat immortalized here forever.
@Wopsx10 жыл бұрын
// Swapping variables #include using namespace std; void changeValue(int *x, int *x2); int main(){ int a = 13; int b = 57; cout
@KunalSharma-jy7he10 жыл бұрын
u dont know what a big deed u have done by doing this Thank You
@UnrealEngine_Master10 жыл бұрын
python way to da the same: a, b = b, a that's all :)
@MrQwerty25249 жыл бұрын
Tema Lavrov Python is called a Toy language for a reason.
@UnrealEngine_Master9 жыл бұрын
MrQwerty2524 LOL!!!
@justinek94617 жыл бұрын
I know this is an old comment, but I want to ask about this line: *x = *x2 For *x and *x2 to be equal, does it change *x to *x2, or does it change *x2 to *x? It seems to be the former, in order for your function to work. Also, if I'm right, is it always the left hand side changing its value to the right hand side's?
@DromeG6010 жыл бұрын
This is the first tutorial where I got stuck :/
@jigglywiggly64799 жыл бұрын
DromeG60 Same here.....
@PS2Damon9 жыл бұрын
DromeG60 printing by value doesn't change shit printing by reference changes it
@johnnycat9958 жыл бұрын
PS2Damon basically yes
@marinalance81988 жыл бұрын
Thank you so much! This was very useful. :)
@KingMartinelli10 жыл бұрын
WHY DO YOU KNOW SO MUCH
@FINEDIAMOND13 жыл бұрын
You explained this so well! I understand it now! Thank you! =)
@JamesBrodski6 жыл бұрын
4 e's? That way too many haha!! Great videos dude!
@b1rebel11 жыл бұрын
Aww man that was so helpful thats a load of my mind, thanks
@guitarheroprince12311 жыл бұрын
What you actually said is call by address and NOT call by reference.. People are really confused between reference and address.
@goldse2611 жыл бұрын
when you only need the value, say you have a function that calculates the area of something and you want the user to input the values, you don't need to change the original one's values, you only need to copy them to do something else
@starman53089 жыл бұрын
Sorry guys, I'm confused now. If passByValue doesn't actually change the variable, why do getter & setter functions work? Because when we use setTuna(int x) to set the value of "tuna" and then call getTuna() to get the value of "tuna", it returns the value modified. Isn't it contradictory? Or am I missing something here? If anyone could help me it would be great. Thanks!!
@dave369_ Жыл бұрын
A setter function is typically part of a class, that is changing a variable within the class's scope. The variable can be changed because the setter has access to it. But the PassByValue function here is just given a copy. The original is not in scope, the parameter is. Hence only the parameter is changed.