Тёмный

REFERENCES in C++ 

The Cherno
Подписаться 662 тыс.
Просмотров 578 тыс.
50% 1

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 609   
@LuskyMJ
@LuskyMJ 2 года назад
I'm laying with my phone at 3:14 am on christmas eve and watching c++ tutorials. What has my life become.
@lucasgroves137
@lucasgroves137 Год назад
Yes. That is sad.
@LuskyMJ
@LuskyMJ Год назад
@@lucasgroves137 I actually felt pretty happy at that moment.
@lucasgroves137
@lucasgroves137 Год назад
@@LuskyMJ So you were crying wolf. And on Xmas Eve too. 😄
@SOME_BORED_GUY
@SOME_BORED_GUY Год назад
After a year now I'm sure that you realized you did the right thing 👍
@lilfelix8955
@lilfelix8955 Год назад
At least you have a good taste in Anime girls
@ToxicityGameDev
@ToxicityGameDev 6 лет назад
I think I'm going to comment on every one of these videos.... Again, hands down, best C++ videos on the web... hands down.
@benjaminf.3760
@benjaminf.3760 6 лет назад
agree
@GfastGao
@GfastGao 5 лет назад
Any reason with that? Said little boy?
@masasikisimoto26
@masasikisimoto26 5 лет назад
Have you guys seen Bucky's C++ tutorials? They are much better.
@michaelm.3641
@michaelm.3641 5 лет назад
@@masasikisimoto26 Bucky covers a lot and does it quick, but he doesn't go to the same depth that Cherno does when describing concepts. Speed isn't always better, and Cherno ensures to cover a lot of important concepts that Bucky doesn't necessarily get to in an appropriate manner. That being said I enjoy both of their videos.
@sarveshkaran9380
@sarveshkaran9380 5 лет назад
Truly appreciate these stuffs. Its a bench mark for a standard video
@KamilKhanYT
@KamilKhanYT 4 года назад
He talks about references like the priest talks about angels.
@ppbb6699
@ppbb6699 4 года назад
that's right
@HaragothNAR
@HaragothNAR 4 года назад
It really is fascinating, I lost my shit when I learned about pointers/references.
@omearsaeed
@omearsaeed 6 лет назад
Truth be told! your explanations are much much better than the paid lynda courses on C++! Thank you for these amazing videos!
@biqbicle4982
@biqbicle4982 Год назад
yeah maybe cause your teacher probably never had a job at ea💀 its the hard truth
@Aaronmac404
@Aaronmac404 5 лет назад
Once C++ starts clicking for you, it REALLY makes sense. Damn. No wonder this shit has been industry standard for so damn long.
@contruq
@contruq 3 года назад
i kinda got problems with learning C++, so i rewatch these vids
@DragonKidPlaysMC
@DragonKidPlaysMC 3 года назад
@John McGee rust will take over c++
@hmthatsniceiguess2828
@hmthatsniceiguess2828 3 года назад
@@DragonKidPlaysMC Rust isn't taking over anything, definitely not C++. You don't realize what you're saying. Apart from some more narrow use cases, C++ will reign supreme for a long time.
@VivekYadav-ds8oz
@VivekYadav-ds8oz 3 года назад
@@hmthatsniceiguess2828 Almost the entirety of Firefox is written in Rust. Chromium has started including Rust in it. Hell, even the Linux kernel, which shunned C++ from its codebase, is going to start using Rust in it. C++ is fun to write and experiment in, Rust is not. It's a bit locked down. Rust is fun to write a serious application, when memory leaks become a serious issue and GC isn't an option and smart pointers are too much of a runtime overhead for you liking.
@kallht2079
@kallht2079 3 года назад
I really hope I'll reach that point
@Tracks777
@Tracks777 7 лет назад
Great content
@etiennewijler6830
@etiennewijler6830 4 года назад
Mate, your videos are the best. Just to give you some insight into the variety of your target group and the impact that your videos are having: I'm an assistent professor in Econometrics at a top international university. As part of my research, I have developed novel statistical estimation procedures that work great for high-dimensional datasets (big data). The estimators can be computationally heavy and I have always programmed them in R, which made the computations painstakingly slow. A year ago, with the help of your videos, I made the switch to C++ (through the use of Rcpp) and my code has sped up x100. Not only have I been able to obtain valuable scientific insights by means of simulations a lot faster now (and publish them faster in academic journals), I have also turned my code into R packages, backprogrammed in C++, and made it available for other researchers. This explanation on passing by reference alone has saved me and researchers using my package a ton of time! Thanks a lot and please keep doing what your doing.
@serhiih.4724
@serhiih.4724 Год назад
100%
@joebruh8230
@joebruh8230 2 года назад
That incrementing integer through memory addresses part is what really blew my bloody mind. Lower level languages never cease to surprise me. Coming from python, I feel like I'm capable of black magic now.
@NphiniT
@NphiniT 11 месяцев назад
Black magic 😅
@theseangle
@theseangle 8 месяцев назад
Wait till you learn C
@NovacStudios
@NovacStudios Месяц назад
Trust me my mind is more blown im coming from roblox studios Luau 💀
@davidbatetc
@davidbatetc 7 лет назад
These videos are so useful! Thank you for your time :)
@daginganinja4075
@daginganinja4075 4 года назад
The most articulate videos regarding computer programming that I have ever watched! I know this is a very "old" video at this point and, perhaps, there are better ones to comment on but there are clearly still people benefiting spectacularly from this series. I guess you're still the best of the best!!
@cagdascevrim69
@cagdascevrim69 3 года назад
dude these videos are like three years old now so idk if you're gonna read this but you are so helpful thank you so much
@sfondi0801
@sfondi0801 5 лет назад
You are great but it's slightly unnerving how you never blink
@alphatier4919
@alphatier4919 6 лет назад
By the way... This: #define LOG(x) std::cout
@konsulan7576
@konsulan7576 5 лет назад
@@rrmm5453 Because 16 in binary is 0001 0000. He is bit-shifting it to the left by 2 (16
@RandomDays906
@RandomDays906 4 года назад
@Neel Shukla when the preprocessor sees '
@idk-bv3iw
@idk-bv3iw 4 года назад
@@RandomDays906 The preprocessor doesn't see anything, it just copy-pastes code and just replaces x with the argument. So std::cout
@piechulla1966
@piechulla1966 4 года назад
@@idk-bv3iw This is why Stroustrup (and everybody else) warns against the preprocessor. Or at least against overuse. But most of the time we are working with 'legacy code', so we have to be aware of the pitfalls and endure the headaches.
@AlexTheGreatish
@AlexTheGreatish 6 лет назад
5:34
@wallaceobey651
@wallaceobey651 6 лет назад
*subscribes* Also, if you have time I'd really appreciate a data structures playlist in C++ specifically.
@obama7563
@obama7563 3 года назад
look up mycodeschool they have alot
@alsayedalsisi2709
@alsayedalsisi2709 7 лет назад
Man, you're really awesome. I have seen many many tutorials in many topics before, but I have never seen such high quality nor someone who has such knowledge or clear way to explain things like you. I am really a big fan of yours.
@platch23
@platch23 5 лет назад
Every video in this series is absolute gold. Such clarity. I'm curious how much of this changes with C++14
@daniazzam1161
@daniazzam1161 2 года назад
I am new to this series, is there a lot of changes in the newer Cpp versions?
@wowvain2989
@wowvain2989 Год назад
@@daniazzam1161 newer CPP versions almost never affect core concepts such as variables, normal pointers or references so you dont have anything to worry about. Only the advanced concepts of the langauge can change with a new CPP version/standard
@beebstergames7348
@beebstergames7348 Год назад
I have been a 'C' programmer for over 40 years. I was a systems programmer for Unix. I came here to get an explanation of Variable References and I just want to say thank you. I watched a few other videos but this was the best explanation. Thank you for being simple, concise, and clean in your explanation.
@Hoptronics
@Hoptronics Год назад
​@@forbidden-cyrillic-handle same.
@roboking1020
@roboking1020 3 года назад
I'm not exactly sure if this series is beginner friendly. There are places where if I was a beginner, I feel like I'd be totally confused (then again that might not be the case for everyone). But as an intermediate programmer coming from C#, this stuff is pure gold. Super helpful and very well explained.
@AlaaAreesPhoenix
@AlaaAreesPhoenix Год назад
no this series is clearly not to follow from scratch , but when u get familier with basic stuff this is 100% the best place to come.
@heavymetalmixer91
@heavymetalmixer91 Год назад
As you say, it's not mean for beginners in programming. But, if you already know the basic concepts of programming like variables, conditionals, loops, functions and clases, then this course is really good.
@jasonmathew33
@jasonmathew33 7 лет назад
Thanks for the video! Are you going to be discussing data structures, algorithms and design patterns at all later in this series? just curious
@TheCherno
@TheCherno 7 лет назад
Absolutely.
@angelojulioth3616
@angelojulioth3616 7 лет назад
Yes, I want to see you cover those topics, specially, data structures and sorting algorithms. I love you Cherno!
@matthewe3813
@matthewe3813 3 года назад
@@TheCherno when a comment to a comment has more likes than its parent comment
@CheatCodeSam
@CheatCodeSam 6 лет назад
Currently reading through "the C++ programing language 4th edition" and these video help understanding it immensely. Thank you!
@MsJavaWolf
@MsJavaWolf 5 лет назад
Great book. Once you read a certain level I would recommend it to every C++ programmer, even if it can be a bit scary at first.
@mastershooter64
@mastershooter64 3 года назад
@@MsJavaWolf so... once you learn the basics of c++ you should read "the C++ programming language 4th edition"?
@MsJavaWolf
@MsJavaWolf 3 года назад
@@mastershooter64 I've read it a few years after I started learning c++, so I already knew a bit more than just the absolute basics but I think you can also read it earlier. I would not recommend reading it in the first few weeks or so though, because it is very technical and might be confusing. But I think at some point it's very helpful, it's very thick and thorough, it filled many small gaps that I had als self taught c++ programmer.
@satellite964
@satellite964 5 лет назад
This little 10 min video could've saved me so much pain back in 2016 when I was doing CS at uni. -__-
@muhammedimdaad
@muhammedimdaad 2 года назад
believe me. I am coming from Stroustrup C++ book. I didn't understand references there. and Booooom. it's crystal clear now.
@w3w3w3
@w3w3w3 5 лет назад
Best c++ videos on the web! Thankyou.
@mickyyang6652
@mickyyang6652 2 года назад
In C++, references are just "aliases" of variables, rather than pointers that store addresses.
@interstellarj5218
@interstellarj5218 5 лет назад
I love your no-nonsense explanations in clear english! Please take my horse as payment.
@nicklandreth2527
@nicklandreth2527 4 года назад
So references only exist for the compiler and are never in memory I guess.
@tykesmendoza1191
@tykesmendoza1191 2 года назад
I never knew ed sheeran was a great programmer, such a talented guy!
@abhijatpandey1490
@abhijatpandey1490 4 года назад
Difference between reference and pointers: pointers take up more space than references
@michaelm.3641
@michaelm.3641 5 лет назад
Thank you Cherno for your high quality videos. I don't normally do projects in C++ but I needed to create a plugin for a program that is written in C++ and your videos made this a breeze.
@manuel56354
@manuel56354 5 лет назад
Better explanation than the one found in the "The C++ programming language" by the creator of C++. There I didn't understand a bit. Here I swiftly got it! Thanks!
@nexusclarum8000
@nexusclarum8000 4 года назад
In books like that they don't try to be easy to understand. They try to be precise. Well, being easy to understand isn't the primary objective at least.
@klarnorbert
@klarnorbert 4 года назад
I also got a book from him, but it's like he's talking alien.
@nexusclarum8000
@nexusclarum8000 4 года назад
@@klarnorbert The issue with certain books is they assume prior knowledge in certain areas. It's like if you picked up a calculus book it's going to assume some prior math knowledge. Computer science and programming books can be very much the same. If you're an absolute beginner or nearly that then its something worth looking into before buying a book.
@joelcurtis562
@joelcurtis562 4 года назад
@level90s Second this. Great book. Make sure to get 2nd Edition.
@Sarah-pf4ec
@Sarah-pf4ec 6 лет назад
This video series has been extremely helpful, thank you for making them.
@jzxdrift
@jzxdrift 4 года назад
Can you please make a video explaining rvalue references, universal references, std::move and std::forward? Why we need them, when and where we should use them, etc. Thanks.
@meh1672
@meh1672 7 лет назад
You just explained my biggest confusion! :D
@jdvd
@jdvd 6 лет назад
Hey, great work. I am refreshing my C++ and your videos are great. However, I'd like to point this out: int a = 5, *p_a = &a, &r_a = a; r_a += 5; std::cout
@jeremygong4190
@jeremygong4190 2 года назад
that 3 types of input is amazing! basically included everything you need to know to take advantage of pointer reference and a single variable. Amazing vid!
@juanpablogomezgarcia1835
@juanpablogomezgarcia1835 4 года назад
Best c++ series ever, i understand pointers in 30min after 5 years in college :(
@trungthanhbp
@trungthanhbp 4 года назад
u suck
@Fronzel.Neekburm
@Fronzel.Neekburm 3 года назад
From an old 'C' programmer trying to break old habits and fully convert to 'C++' way of things, these videos are awesome. Short, simple and to the point and even work at 1.5 playback speed. I now have the urge to find out when references was added to the language and if it has anything to do with ".Net"'s arrival?
@juniorcomsono
@juniorcomsono 2 года назад
are you watching his videos on 1.5 playback? i'm even struggling on the normal speed lol
@QuintinMassey
@QuintinMassey 3 года назад
Oh man… this was exactly what I needed to see. Thanks for showing the simple example with the reference to a first, then confusing the crap outta me with function example where you use de-referencing and pointers, then getting me back on track with the pass by reference example. I needed to see the easy then convoluted case before I could understand why the final example was the way to go. You clearly thought that through. You’re awesome.
@jackiez8946
@jackiez8946 5 лет назад
does anyone know why i would get an error of int not compatible to const char* when I try to use the Log() function with a? ie. Log(a);
@jackiez8946
@jackiez8946 5 лет назад
Peterolen Peterolen i think that might be it, but i coded it identically to his. just making sure, he coded the function in the header video right?
@mostafa2199
@mostafa2199 Год назад
Thank you, Ed Sheeren of cpp
@mikethecoder341
@mikethecoder341 3 года назад
if we have ptr pointing to a, can we do ptr ->a++? because I have seen the ptr->a before but I dont know if we can increment
@ghost-ud3bm
@ghost-ud3bm 3 года назад
you'd need to do ptr = &(++a) ig since ++a will first increment the variable, and then do whatever the rest of the code wants.
@yunusmile
@yunusmile 3 года назад
6:16 so fast, couldnt see anything
@Startoucharavos
@Startoucharavos 4 года назад
This guy deserves every cent of patreon support..
@Thadnill
@Thadnill 4 года назад
I am serious when I am saying that you are probably the only youtuber that doesn't make me lose concentration or fall asleep after 10 minutes! Thank you
@sumitkaranjkar3819
@sumitkaranjkar3819 Месяц назад
But remember this at: 02:17 #include #include int main() { int *a,b; int &c=b,d; std::cout
@krishonweb
@krishonweb 3 года назад
the way he uses log i guess he just loves javascript
@TheChemicalBassist
@TheChemicalBassist 5 лет назад
Even though this is about references... Ironically this is an excellent video displaying the usefulness of pointers. Your examples and explanations are top tier.
@reddragonflyxx657
@reddragonflyxx657 7 лет назад
References are constant pointers which are always dereferenced. I think that is a pretty good summary, but tell me if I'm wrong.
@rossengeorgiew9589
@rossengeorgiew9589 2 месяца назад
Semantical nigthmare for adhds and dyslexics folks...it's close, but not the same, it's an int, but it is not....all and nothing at once......................
@thestarinthesky_
@thestarinthesky_ 4 года назад
I have been too lucky to find this course today in RU-vid. It is 12:35 am and I can’t stop watching these amazing tutorial. You should be teaching at Harvard. Please upload videos on optimized C++
@Chevifier
@Chevifier Год назад
My god, all the bulbs are going on(off?). Im enjoying each and every one of these video and also coding along as well using VSCode on Linux. You are a God send👏
@whatisuser
@whatisuser 3 месяца назад
I wish he would have explained return by reference too. That shows something that a normal pointer can't do directly. Like, you can make greater(a, b) = 50; or something and the 50 will be assigned to the greater number. Either a will be 50 or b will be 50 depending on which is greater. You can't normally do this with pointer, you would have to copy the function to something.
@teo-medesi
@teo-medesi 4 года назад
The fact that this is one of the best courses for learning C++, In-depth theory, and clean code and it's free just boggles my mind.
@cheemsinu2147
@cheemsinu2147 4 года назад
Thanks for this awesome C++ tutorial series :)
@DragoEliteN
@DragoEliteN 2 месяца назад
IMHO in a complex structures it is easier to miss that you deal not with the local variable which was set while calling the function. And you could potentially spend some time debugging that. But it could be really helpful if you find yourself typecasting many times.
@팍준하
@팍준하 4 года назад
Guys if you didn't fully understand the video, I REALLY SUGGEST YOU READ THIS COMMENT. If you don't wanna read all, AT LEAST READ THE LAST SECTION. I HAVE A MINDBLOWING DISCOVERY FOR YOU. References are just reference to a variable, which means that it needs another variable that it is assigned. Otherwise, the compiler is going to throw an error. It is so similar to a pointer in a sense that we can replicate everything that a reference can do with a pointer. --------------------------------------------------- It has the syntax of int& ref = a; --------------------------------------------------- Cherno shows an example where he created a function that increments the value of the integer it takes in as an input. Like this. void increment(int value) { value++; } --------------------------------------------------- However, when he used the function with an integer 'a' created and then printed a to the console, we found that a was still the same value before incrementation #include void increment(int value) { value++; } int main() { int a = 5; increment(a); std::cout
@crazychase443
@crazychase443 5 месяцев назад
years of trying to understand references, and now after one of your 10 minute videos i've finally got it. THANK YOU!
@VisweshSuresh
@VisweshSuresh Год назад
struct comp{ int data = 7; int& ref = data; } sim; int main(){ sim.ref = 8; cout
@b213videoz
@b213videoz Год назад
WOW!!! C++ now has what Pascal had ever since 1970ies: passing arguments by reference 🤣😁😂
@lake5044
@lake5044 3 года назад
This is one of the things I really dislike about C++. I just don't get why make a weaker version of pointers that cannot be reassigned. (Adding insult to injury by using the same operator for so many damn things: * pointer, * multiply, * dereference, & reference, & address...) ugh the sloppiness of the syntax is really killing me. I think it's probably due to me being used to C/Java for too long...
@polymakegames
@polymakegames 3 года назад
Lmao. A few years too late Cherno, but I straight failed my CIS class that just taught basic C++ because of this particular chapter kicking my ass. Your explanation just cemented what I felt I found out while working in Unreal engine with their Blueprints. But I was never able to grasp it in a pure C++ environment. Now I do. Thank you man.
@iutubgugal5566
@iutubgugal5566 4 года назад
Hi everyone! Noob here. Can you please help me understand something? When I call Increment(a), on the stack there will be a copy of variable a. How does the reference work? I mean, Chemo says it isn't an actual variable, it isn't the address of it, it is a label that references the copy on the program stack. So when i increment the value, I'm incrementing the value on the stack. How come this works? When I have a pointer, I'm incrementing the value at the address x. So having the address on the stack is fine because I'm not actually modifying that. But the reference doesn't look at that memory location. I'm confused. The video is great, but I lack some knowledge here. Thanks in advance!
@gabrielmaria2762
@gabrielmaria2762 6 лет назад
Watching some of your videos as a total beginner in C++ and coding in general I'm like "Oh, now I get it" in the first half to "What the..." towards the end of the video. Great work by the way! Thanks a lot!
@godjacky2
@godjacky2 5 лет назад
if I just write method this, void println (const string &name){ cout
@VarunPandey
@VarunPandey 5 лет назад
Nice videos, thanks! When do you prefer references over pointers? I always end up using references because it does the job.
@epicbattles3887
@epicbattles3887 2 года назад
reason I`m watching is that I did find something that you cannot do with references and that is "void Increment(void& value){ (int)value++; }"
@drwisdom1
@drwisdom1 5 лет назад
Don't use references, pointers blow them away! Don't be afraid of the -> deref operator, its better than the . operator. Mr. TheCherno says references "look nicer in the source code" and "they are just syntactic sugar". Those are not valid justifications for coding practices and references don't look nicer. I say references make the code more complex, harder to understand, and limit what you can do, all because some people says the ->, a core language feature, is unsightly. Unlike many programming languages which believe programmers can't handle pointers, C and C++ don't hide pointers, they successfully deliver the power of pointers. So if you can't understand pointers and hope that references will get you out of it, then you should choose one of those other languages, not C or C++.
@victorzedwings
@victorzedwings 2 года назад
*The only pitfall is that you don't know if you are passing var by a reference or by the value.* *This is decided by compiler according to callee declaration.* So this may bring some uncertaincy to the mind... The other ugly thing probably is that when you do not the SCU, changing callee will require caller code recompilation.
@philparisi_
@philparisi_ 2 года назад
You are a god among us, dearest Yan. Thank you for being an awesome guide on our journey to conquer C++!!
@maloukemallouke9735
@maloukemallouke9735 3 года назад
Hello Thank s for sharing, if you allow me The Hard Part about pointer and reference is not what is it but when I should use It? (Specaly return Type of function class or template .....)
@dr3d3d
@dr3d3d 2 года назад
I feel so incredibly dumb, iv been programming in C and C++ for years on embedded systems, I never realized that a address reference and a reference were different... I just stumbled my way through it when needed and avoided them if possible(on an embedded system avoiding the issue is easy). I think this is single handedly the #1 reason people think ptrs are hard... they don't realize the ampersand has two meanings and de-referencing is a thing. I cannot believe how dumb I feel right now. also I think to hit this topic home(although maybe he will later) mentioning the benefit of using ptr and de-referencing vs a reference would be to allow for function overloading.
@bioanu
@bioanu 2 года назад
High quality human here!!!!! I still have hope when I meet person like you!!! Thank you!!!
@modo4211
@modo4211 2 года назад
What happens if you have a function which takes a const Referenz of an integer value (like so: void func(const int& value)) and you call the function not with a variable of type int but with a raw number (like so: func(1))? I have trouble with such a scenerio and it seems that the behaviour is differnt then when i pass a real variable of type int into the function. Can anyone explain what goes on there?
@mkhadka123
@mkhadka123 2 года назад
Really Nice...finally I think I understand the two most painful things in c++ ;)
@TwstedTV
@TwstedTV 4 года назад
I keep having to come back to this video over and over, because for some stupid reason I get confused..... (maybe my parents dropped me on my head or something.) but I always thought, that References, reference to the pointer, and the pointer points to the memory location which the variable created....... :(
@dharmamati6370
@dharmamati6370 4 года назад
You are as brilliant as the sun.Thanks a lot. Can we compare references to Linux hard links and pointers to symbolic links? You say pointers and references are easy but when you see them pop up in larger pieces of code it STILL can get confusing....
@hayden3774
@hayden3774 2 года назад
References are not just "syntax sugar" and are not essentially the same as pointers, and you certainly CANT do everything a reference can do with a pointer... example: you CAN make a reference to a pointer, but you CANT make a pointer to a reference (makes no sense). Also, references can't refer to objects that are meant to change throughout their lifetime.. things that are dynamically allocated on the heap, which pointers were meant to be used. There is a reason references and pointers are confusing, it is not this simple.
@Djzaamir
@Djzaamir 7 лет назад
Great video as always , even though i know these concepts but your videos further clarify my concepts Thank you.
@Jschm_
@Jschm_ 5 лет назад
My prof says that we should use books instead of watching RU-vid videos... Fuck that guy Yeah of course I read the books too but this much more relatable for me , so thanks for existing
@sorinjayaweera8751
@sorinjayaweera8751 2 года назад
Quick q: why not use a global variable and not define it in the function declaration? That seems easier to read, is it to minimize memory useage? I dont understand... thanks!
@groundzero6262
@groundzero6262 3 года назад
I wish the & placement was also discussed, same with the * (or was it discussed in another video?) I was watching the const vid and I am just confused where to properly place that asterisk/ampersand because it seems you can put it right after the type, before the pointer/reference variable, etc.
@barnacora
@barnacora 4 года назад
how is the background music helpful? This is really distracting for me.
@sasha2209
@sasha2209 5 лет назад
I don't Know why Should We use Pointers ? And When Should We use it ? Like i search A lot on internet i could not find any Right Answer Can You please Explain It to Me ? why and when should we Use Pointers ?
@SyIvIus
@SyIvIus 5 месяцев назад
The last example may be used in games like Final Fantasy, when you switch the character in action.
@tonychristney2728
@tonychristney2728 4 года назад
You skipped over a practical benefit to references over pointers - clarity around the pointer/array ambiguity. It's not just syntactic sugar, but a key part of writing type safe code.
@roja
@roja 2 года назад
Commenting for your exposure. The best channel on RU-vid for C++ !!!
@ProjectKneepads
@ProjectKneepads 2 года назад
If I understand references correctly then, there would be a marginal benefit to using references over pointers (provided you don't need to change the reference) since you're not allocating memory for a new pointer variable but just "renaming" an existing variable.
@AlainDjiZ
@AlainDjiZ 2 месяца назад
the most great c++ course
@mgking777
@mgking777 3 года назад
The best explanation video for references very good thank you so much !!!!
@user-rl9ou7vz6t
@user-rl9ou7vz6t Год назад
Hopefully someone can help me understand this and probably let me know I'm being dumb but at 6:48 when he writes int& how does the program know what int he is referencing?
@yadav-r
@yadav-r 2 года назад
I was frustrated with this & but now it seems all clear, everything makes sense now. ThankYou
@rafailand3239
@rafailand3239 6 лет назад
So actually reference it's giving a "second name to an exist variable". Does a reference take memory? If it's not then isn't better to use a reference because pointers take some memory because you are creating a variable with the address of another variable? Sorry for my english ;)
@vimleshkumarkanaujiya
@vimleshkumarkanaujiya 3 года назад
Your all videos are saving my life in August 2021. Thank you.
@yumje3377
@yumje3377 2 года назад
You explain every concept in a so concise and understandable way. Helped me a lot. Thx.
@2khz
@2khz 4 года назад
Seeing a man in his kitchen talking about C++ is bizarre, but a nice breath of fresh air from a man talking behind screen capture software
@ykyjohn
@ykyjohn Год назад
variable are really just an reference to a memory if you will. A pointer is a special variable which holds memory address but essentially is a reference to a particular memory which will hold an address of another address of memory. The same comparison you did between types of memory. It all does about the same essential thing.
@filipbarbaric1960
@filipbarbaric1960 Год назад
One of my first qustion on intervu was what is difference between pointer and reference. Give specific example? Ther are not the same. Pointer can change what they are pointing to but references canot, pointers can be nullptr.
@Aaackermann
@Aaackermann Год назад
To directly write to a memory adress could bear the risk of damaging (i e deleting) memory that is used by for instance the operating system and therefor crash the whole system. Right?
@salmannadaf7433
@salmannadaf7433 Год назад
Wanted to add just one point: With pointers you can have multilevel indirect referencing which is not possible with references.
Далее
CLASSES in C++
8:42
Просмотров 671 тыс.
Being Competent With Coding Is More Fun
11:13
Просмотров 84 тыс.
Лайфак года 😂
00:12
Просмотров 93 тыс.
2 Years Of Learning C | Prime Reacts
22:24
Просмотров 290 тыс.
POINTERS in C++
16:59
Просмотров 1 млн
lvalues and rvalues in C++
14:13
Просмотров 316 тыс.
Naming Things in Code
7:25
Просмотров 2,1 млн
31 nooby C++ habits you need to ditch
16:18
Просмотров 789 тыс.
References in C++ Explained
14:21
Просмотров 101 тыс.
Stack vs Heap Memory in C++
19:31
Просмотров 569 тыс.