OPERATORS and OPERATOR OVERLOADING in C++

  Рет қаралды 367,825

The Cherno

The Cherno

Күн бұрын

Patreon ► / thecherno
Twitter ► / thecherno
Instagram ► / thecherno
Discord ► / discord
Operators Reference ► en.cppreference.com/w/cpp/lang...
Series Playlist ► • C++
Gear I use:
-----------------
BEST laptop for programming! ► geni.us/pakTES
My FAVOURITE keyboard for programming! ► geni.us/zNhB
FAVOURITE monitors for programming! ► geni.us/Ig6KBq
MAIN Camera ► geni.us/t6xyDRO
MAIN Lens ► geni.us/xGoDWT
Second Camera ► geni.us/CYUQ
Microphone ► geni.us/wqO6g7K

Пікірлер: 407
@sankalpsharma1755
@sankalpsharma1755 2 жыл бұрын
This guy is legit, for some reason after using C++ for 4 years, i feel like i never learned the language enough
@Tuho420
@Tuho420 Жыл бұрын
@@GH-jl2td this serie is more for beginners
@amosreginaldjr.4200
@amosreginaldjr.4200 Жыл бұрын
I’ve heard stories of people that’s been using c++ for 25+ years and they say it’s impossible to know everything. You learn it as you need it
@Tuho420
@Tuho420 Жыл бұрын
@@amosreginaldjr.4200 yeah c++ is closely impossible to "master"
@BlueDippy
@BlueDippy Жыл бұрын
@@Tuho420 chill😭
@Tuho420
@Tuho420 Жыл бұрын
@@BlueDippy why
@jerfersonmatos28
@jerfersonmatos28 4 жыл бұрын
After pausing the video 3 times, and meditating I finally got it, thank you Cherno
@lucasmorais3694
@lucasmorais3694 3 жыл бұрын
Ih ala, camisa do framengo brabo
@debjitmondal5281
@debjitmondal5281 2 жыл бұрын
soo true lol
@jerfersonmatos28
@jerfersonmatos28 2 жыл бұрын
@@lucasmorais3694 kkk, nois é hardcore
@lucasmorais3694
@lucasmorais3694 2 жыл бұрын
@@jerfersonmatos28 cara esperou dar 1 ano pra responder LOL
@jerfersonmatos28
@jerfersonmatos28 2 жыл бұрын
@@lucasmorais3694 é que eu nao tinha visto, mas de qualquer forma desde essa épouca que eu nao pratiquei mais programação kk, lembro mais de nada
@nakon7niket
@nakon7niket 2 жыл бұрын
Sometimes. you just go through so much information and you understand it but you don't really understand it. Then sometimes, you stop to think and apply what you just learnt and you really understand the concept and you feel like your brain just expanded a little. This is happening too frequently since I have started watching this series.
@eddyecko94
@eddyecko94 4 жыл бұрын
Love this channel, I wish I found it 5 years ago back in university
@justasydefix6251
@justasydefix6251 3 жыл бұрын
5 years ago, he wasnt even here doing c++ tutorials
@user-ic5nv8lj9d
@user-ic5nv8lj9d 2 жыл бұрын
@@justasydefix6251 lol
@puppergump4117
@puppergump4117 2 жыл бұрын
I found him 22 years ago when I was just starting
@benjaminbirchman3732
@benjaminbirchman3732 Жыл бұрын
Cherno, thanks for these videos. After taking a year off of coding after school to pursue something else, reviewing these topics from a real-world use-case standpoint makes them make a lot more sense as to what they are useful for compared to how we learned them in school. Yes, we learned them well in school, but it was rarely made clear as to what the expected usage of each topic should be. I now have a better understanding of when I should overload operators!
@xonxt
@xonxt 5 жыл бұрын
Basically do a: Vector2& operator++() { return (*this)--; } Vector2& operator--() { return (*this)++; } And watch the world burn. Pity that it wouldn't work.
@benjamin_boeri
@benjamin_boeri 4 жыл бұрын
You're evil, man
@nazeekk3873
@nazeekk3873 3 жыл бұрын
Or do: #define ++ --
@mrpedrobraga
@mrpedrobraga 3 жыл бұрын
@@nazeekk3873 mmmm my favourite language, C--
@kenan2386
@kenan2386 3 жыл бұрын
@Pedro Braga and mine C**
@Glomly
@Glomly 2 жыл бұрын
@@nazeekk3873 well your example will replace all ++ with -- . But in example above it will just call an infinite loop. IF any of it worked :)
@cortisol_induced_coma
@cortisol_induced_coma 2 жыл бұрын
Learning this in my CS class kinda made me die inside. I was able to understand you much more easily, thank you!
@codysing8291
@codysing8291 7 жыл бұрын
Just what i was interested in. Thanks for the great stuff
@hugoalmeida1291
@hugoalmeida1291 Жыл бұрын
This series is FABULOUS Cherno! You've clarified all of my doubts, thank u buddy =D
@lisandrob626
@lisandrob626 4 жыл бұрын
man, I must seem crazy being alone and clapping after each amazing video, TXS
@mattgraves3709
@mattgraves3709 3 жыл бұрын
Boy thanks again. This series has been on loop in my home for 3 months. I have been needing to override the ostream and was wondering what to do... and == TY for showing those useful tips
@jmg_1615
@jmg_1615 5 жыл бұрын
Thank you! I had difficulties with this but you made it a lot clearer.
@antoinefortin1386
@antoinefortin1386 5 жыл бұрын
So clear, so neat and so well explained.
@LS-to6qv
@LS-to6qv 9 ай бұрын
Taking my first programming class and this series has been really helpful. Thank you.
@kenan2386
@kenan2386 3 жыл бұрын
Me and the bois watching The Cherno and growing brain cells
@lolxdroflmao431
@lolxdroflmao431 3 жыл бұрын
By far my hardest C++ lesson, might have to review previous lessons
@Mandeepsingh-jo5cf
@Mandeepsingh-jo5cf 3 жыл бұрын
master class on operator overloading . Note: playback speed: 0.75;
@princessntomo6008
@princessntomo6008 2 жыл бұрын
thanksss🤧😂😅
@TW19567
@TW19567 Жыл бұрын
Wonderful explanation! Truly truly wonderful explanation of a pretty tricky concept to get your head around initially. Now it all makes sense.
@Day13May
@Day13May 5 жыл бұрын
This is so much more clear now! thanks!
@benjamin_boeri
@benjamin_boeri 4 жыл бұрын
I'm loving C++ and your series
@shayaxelrod7691
@shayaxelrod7691 3 жыл бұрын
Dude.. Don't know why I read: "I'm loving c++ and your SISTER
@puppergump4117
@puppergump4117 2 жыл бұрын
@@shayaxelrod7691 My sister is already taken by me
@shayaxelrod7691
@shayaxelrod7691 2 жыл бұрын
@@puppergump4117 k
@pypunk6248
@pypunk6248 5 жыл бұрын
i got stuck with an assignment for school, also using a Vector2f class in c++, this video got me started :D thx, i appreciate the help
@aarushiagarwal8938
@aarushiagarwal8938 Жыл бұрын
It was really an informative video.Thanks Cherno😀
@insomicraiddict
@insomicraiddict 4 жыл бұрын
That was some fast talking.
@rajshekhar2953
@rajshekhar2953 4 жыл бұрын
not that fast I still have to download and watch it on 3x seed
@yasmin9718
@yasmin9718 4 жыл бұрын
@@rajshekhar2953 ok
@gengar807
@gengar807 3 жыл бұрын
@@rajshekhar2953 Weird flex but okay
@erwinschrodinger2320
@erwinschrodinger2320 3 жыл бұрын
I enjoy it being fast. I hate it when tutorials/guides go super slow.
@aligohar1708
@aligohar1708 3 жыл бұрын
😂 you can't even get a playback on 3x seed.
@tomitomi7941
@tomitomi7941 Жыл бұрын
Man, you are amazing, thank you a lot for your videos.
@RussTeeTrombone
@RussTeeTrombone 6 жыл бұрын
Bloody great video
@lmnefg121
@lmnefg121 4 жыл бұрын
just love your lectures~!
@techwithjordan
@techwithjordan 3 жыл бұрын
I wish my brain would move as fast as you type
@ChrisWong-rq1sc
@ChrisWong-rq1sc 2 ай бұрын
As a beginner in C++, I feel like I got into the wrong room. Anyway, you have done a great job so far.
@resignurdrnk7535
@resignurdrnk7535 4 жыл бұрын
thank you for sharing your knowledge
@harleendiaries
@harleendiaries 2 жыл бұрын
I had to pause the video in the middle to like and subscribe because it's worth it.
@jingyaoyu2173
@jingyaoyu2173 4 жыл бұрын
well done! I finally understand!
@roozbehvalavi8700
@roozbehvalavi8700 Ай бұрын
Never fails to amaze me!
@eman5300
@eman5300 3 жыл бұрын
Cherno My bro your one of the best teachers I've had and I didn't even pay you shit ! love your stuff man !!!
@SeanForeman
@SeanForeman 4 жыл бұрын
"I left out operator overloading (in java) as a fairly personal choice because I had seen too many people abuse it in C++. " James Gosling
@SeanForeman
@SeanForeman 4 жыл бұрын
@Peterolen I was just quoting Gosling (creator of Java) on why java doesn't have it... which is a dumb reason. I think we agree.
@ultimatedragon4281
@ultimatedragon4281 2 жыл бұрын
It is kinda like why Python doesn't have an easy, intended way to break out of a nested loops. The intended way is (if memory serves right) to write an if and break (or continue if you just want to skip that iteration) on EVERY SINGLE LEVEL NESTED LEVEL OF LOOPS. (rolling my eyes so hard I almost can look directly into my brain)
@elhdllo9747
@elhdllo9747 4 жыл бұрын
Thank you that's exactly what I need. our instructor is just telling us non senses in school
@elhbailodiallo2629
@elhbailodiallo2629 4 жыл бұрын
Shivam Panwar ok lets assume that I don’t know how to write an operator overloading, I just don’t see in anyway you business in that? Please can you mind your business ignorant!
@Ethorbit
@Ethorbit 4 жыл бұрын
@@VideoHow And I'm pretty sure you can't structure a sentence properly because you're illiterate.
@lucasmorais3694
@lucasmorais3694 3 жыл бұрын
The best part is Cherno is criticizing the Boost.Serialization Library xD
@joshvictor110
@joshvictor110 5 жыл бұрын
I love how he gets tired of all the card thing lul
@huongpham3580
@huongpham3580 3 жыл бұрын
you literally saved my life!
@rcookie5128
@rcookie5128 7 жыл бұрын
that's really cool!
@ncstarr2716
@ncstarr2716 4 жыл бұрын
your channels the best c++ tutorials on you tube without a doubt but man c++ is soooo much harder than python or php my brain is literally frying listening to you
@freddy7304
@freddy7304 4 жыл бұрын
very challenging stuff to understand. wow.
@nishatmunshi4672
@nishatmunshi4672 Жыл бұрын
very informative thank you a lot
@Destrio_Fury
@Destrio_Fury 2 жыл бұрын
"What are you doing" *stares hard* LOL😆
@patrickmayer9218
@patrickmayer9218 Жыл бұрын
If people need to go to the definition of your operator to understand what it does, you're probably not doing your job. Great video, Cherno!
@letranminhkhoa7492
@letranminhkhoa7492 3 жыл бұрын
some powerful stuff, really.
@antoniothomacelli
@antoniothomacelli 5 ай бұрын
Thank you for share!
@TheMR-777
@TheMR-777 4 жыл бұрын
At [ 5:57 ] you may have noticed he used the *operator* along with the *function* for the addition (which is defined just above that code by the way). Many of you may have thought ... Hey, can it cause performance issues !? , or can lead to slightly lower performance, the answer is ... *Yes* , but it depends ... - If you're making a *specific program* (for yourself), then do make a *single operator* , not along with the function.. As, it is really unnecessary. - If you're designing your own *specific Library* , then do what *Cherno* did. It will increase the *Functionality* and the *Flexibility* of your Library class. _Long story short ... It all depends._
@yrds96
@yrds96 2 жыл бұрын
What kind of performance can this leads? If a compiler sees a function using const parameter it will probably optimize this inlining function which will not call a function creating another stack to the program(unless you compile with debugging flags of course).
@TheMR-777
@TheMR-777 2 жыл бұрын
@@yrds96 Yes I agree, but there are cases, when you have a long and complicated library to make things more abstracted (i.e. ranges-v3, or fmt), and user is heavily dependent on it. In such cases, not all compilers are able to optimize, and inline everything as we expect (I have actually seen the differences, in C++ Weekly logs). And I agree with your point as well, it really doesn't matter, if we have a simpler class. But for long and complicated ones, just imagine that not everything can be optimized, and you are still responsible for many things. :)
@Reydriel
@Reydriel 2 жыл бұрын
@@TheMR-777 Isn't there a way to make sure the compiler inlines the function?
@TheMR-777
@TheMR-777 2 жыл бұрын
@@Reydriel Actually, it depends on the Compiler's Vendor, but still, there are some universal cases, where functions are inlined for sure. Like; - Calling any Function only once - Member Function, used only once - Calling the Function, having a few lines of code (roughly 3, or a little more), and called 2-3 times (or a little more). - Function with just a return statement (highly inlinable) But, sadly, there's no way to find explicitly whether the function will be inlined by the compiler. But if you meet any of the above cases, the compiler will optimize and inline your code for sure. Well, Compilers are quite trustable if you ask :)
@Reydriel
@Reydriel 2 жыл бұрын
@@TheMR-777 Looked it up, apparently you can set a flag in GCC to force inlining wherever the "inline" keyword is used, but it's not the standard behaviour
@starrio713
@starrio713 3 жыл бұрын
I got so confused when I saw std::string. 🤣 This vid really saved me! Thx for the content!
@matthewbrian6191
@matthewbrian6191 3 жыл бұрын
I just did the calculation on the PowerUp Vector and the Speed Vector, and it turns out that PowerUp is actually slower!
@mrboyban
@mrboyban 3 жыл бұрын
Cherno deserves a medal!
@mariadevina5594
@mariadevina5594 5 жыл бұрын
i think you are thinking faster than other people like 1.5x speed, thats why you code so fast and can produce everything quickly. lucky for you!
@mostafamagdy7731
@mostafamagdy7731 5 жыл бұрын
I think you do him a disservice attributing his skill to luck whilst it truly is a skill built up through practice & hard work, like any other sensible human would know and do to get proficient at anything. Live long!! Live average!! That mentality bugs me. I hate procrastination and rationalizing.
@evermatter9041
@evermatter9041 5 жыл бұрын
Also he edits this, and has planning time like Batman.
@whenevertrevor
@whenevertrevor 4 жыл бұрын
But somehow I still understand perfectly. There are so many other tutes around that speak at half the rate, yet struggle to deliver the content in an understandable format. It all seems so much more easier to learn after i watch your videos. Well done Cherno! Thanks
@pxolqopt3597
@pxolqopt3597 4 жыл бұрын
He built his career around making programming and he has been doing this for his whole life. It isn't luck that he is so fast, its hard work and dedication that brought him to where he is today
@kenan2386
@kenan2386 3 жыл бұрын
I haven't understood this for a year, and this guy explains it in 7 minutes *_wow_*
@puppergump4117
@puppergump4117 2 жыл бұрын
Well it's not that complicated. You musta had some shoddy teachers.
@TonyDaExpert
@TonyDaExpert 3 жыл бұрын
Binge watching these before my data structure c++ based class in Uni
@muhammadtaimourafzal5285
@muhammadtaimourafzal5285 3 жыл бұрын
blows my mind
@deleater
@deleater 4 жыл бұрын
Are your eyes really that color, it's cool man !
@e.i.p3471
@e.i.p3471 2 жыл бұрын
Looking at his videos make me feel like i am smart I know that i don't know what he is writing. But I still know what is trying to do
@lyons1652
@lyons1652 3 жыл бұрын
tysm very useful
@GfastGao
@GfastGao 5 жыл бұрын
Just jump back to say thank you & clicked the thumbs up button for this video. Is there anyone like me have the same feeling: See your tutorial save me to click "x1.5" or "x2" botton.
@calebbarnes5452
@calebbarnes5452 4 жыл бұрын
So sick.
@Vladislav0Art
@Vladislav0Art 4 жыл бұрын
Nice vidoes, probably best on youtube! I have a question: can i write my own oparetors, for example, operator === instead of overloading native == ?
@damnstupidoldidiot8776
@damnstupidoldidiot8776 4 жыл бұрын
Not like that. However, you can make user defined literals which are like suffix operator unsigned long long operator""_sqr(const unsigned long long&x) { return x*x; }
@mgottot
@mgottot 10 ай бұрын
Thank you this helped operator overloading click
@zanzuu1249
@zanzuu1249 5 жыл бұрын
Thanks! Love your video! and for ppl saying it's fast, just slow the video down or re-watch it. he is clear and straight to the point.
@michaelswahla4927
@michaelswahla4927 2 жыл бұрын
If it helps from a python view, think of these operator overloading methods as deprecated methods from python (such as def __str__ and def __add__).
@lijacky160
@lijacky160 2 жыл бұрын
Love u!
@kiyasuihito
@kiyasuihito 11 ай бұрын
I'd be interested in a video about move assignment, copy assignment, assign by reference operators.
@chainonsmanquants1630
@chainonsmanquants1630 3 жыл бұрын
Thanks
@lazboi5686
@lazboi5686 Жыл бұрын
amazing
@hanyuzhang4636
@hanyuzhang4636 2 жыл бұрын
For equal operator, do we need to define an errorThreshold epislon and compare two Vector difference with that epislon? Otherwise, the comparison result may be inaccurate.
@maxpricefield7586
@maxpricefield7586 5 жыл бұрын
i'm working on a matrix library that works off of contiguous memory, so the basic way of accessing an element is Matrix[ columns*i + j ]; how can I implement operator overloading of [] such that I can still access it like Matrix[ i ][ j ]?
@phantomstriker7996
@phantomstriker7996 Жыл бұрын
Operators are functions and they make code look better.
@aleshinteregger8554
@aleshinteregger8554 3 жыл бұрын
my university professor has not shown a single code during all of his lectures, just explained dry theory. i really don't know why i go to university at all
@rudrOwO
@rudrOwO 4 жыл бұрын
How do I customize the debug console Visual Studio 2019 ?
@gabrielbraz9669
@gabrielbraz9669 Жыл бұрын
11:00 I believe the compiler is able to auto generate the operator!= if you opverload the operator==, so you don't need to define your own, since the compiler just will negate the other operator you have defined.
@user-qx7zu7xg6u
@user-qx7zu7xg6u Жыл бұрын
I tried. My compiler will say "error: no match for 'operator!='"
@nathanielsicard
@nathanielsicard 5 жыл бұрын
can you create custom operators? for instance if i wanted to make a class that represented a polynomial function and i wanted a member function that took its derivative would I be able to make say d an operator or would I have to either use a preexisting operator (making it harder to read) or be stuck with just the function?
@TommySnow-uj7zn
@TommySnow-uj7zn 9 ай бұрын
i can't believe that this is free.
@abhisheksahoo7446
@abhisheksahoo7446 3 жыл бұрын
Nice one, Your T-shirt , that painting in the wall , your eyes all have the same hue of green Is it coincident or planned :P
@abhisheksahoo7446
@abhisheksahoo7446 3 жыл бұрын
Looks planned
@adamsperry2248
@adamsperry2248 6 жыл бұрын
Is the purpose of returning stream in the
@janusztarczykowski9003
@janusztarczykowski9003 5 жыл бұрын
Yeah, that's the reason, chaining is a really useful thing, especially you are going into functional programming
@floppy-disko2378
@floppy-disko2378 3 жыл бұрын
Thanks your question/answer cleared my dubt.
@cajogos
@cajogos 4 жыл бұрын
This is definitely one of the best things in C++ imo :)
@pxolqopt3597
@pxolqopt3597 4 жыл бұрын
c++ is like the android of programming languages, it has lots of customization and styles in a single fast language
@Mycrosss
@Mycrosss 3 жыл бұрын
Its pretty useless though, you can just make a function that does this, like in all the other languages. Its meant to be an objective language, yet it does shit like this which take away from the objects readability.
@SilverRyuu
@SilverRyuu 3 жыл бұрын
@@Mycrosss imo it makes the code look cleaner. Plus, you don't have to use it if you don't want to. I can see why it would be annoying if someone did something dumb with it though.
@Mycrosss
@Mycrosss 3 жыл бұрын
@@SilverRyuu it is supposed to be more clean and readable, and in some cases it is (like doing this for fractions, since the everyone knows the rules), but in a lot of cases ive seen it creates confusion. Had a coworker make a + operator for a ball, and saw it in few parts of code so i was curious what it did. It fucking added the radius of one ball to the other and made a new, bigger one. Weird shit like that is why i advise people to avoid these operators and just make a function called combineRadius, or enlarge or something to describe it a bit. Cause how do you add 2 balls? You could do it in many ways, and all of them would be hard to predict without actually going into the object and reading the operator function.
@SilverRyuu
@SilverRyuu 3 жыл бұрын
@@Mycrosss That's what I meant with dumb stuff. What does it mean to add two spheres? That's not intuitive. But adding two vectors or two complex numbers? If you wouldn't use a plus to represent the operation in real life you shouldn't use it in code.
@joereinold6495
@joereinold6495 2 жыл бұрын
Can you ID an IDE that would highlight overloaded operators, such as color coding. It does make easier to read the code.
@anrkarpov3763
@anrkarpov3763 3 жыл бұрын
Why the output stream operator overloading function must be declared outside the struct scope ? why couldn't we declare it inside the struct ?
@JimD20619
@JimD20619 Жыл бұрын
C++ gives you full control, which can kinda be a bad thing. Yeah, like allowing someone to write 24 bytes of random data to address location 0 of every hard drive on the system. Every hard drive. No, I wasn't that guy, I was the guy that had to see why running the application resulted in rebuilding the system disk and data drives.
@huiyen2976
@huiyen2976 Жыл бұрын
Hey, Cherno, I really enjoy your video. I try to practice your technique. However, " return *this + other; " not work for me. I compile it with gnu g++. Is there any thing I missed?
@omarshahin4881
@omarshahin4881 4 жыл бұрын
I implemented leftshift operator as I said but gave an error like "ISO C++ forbids declaration of 'stream' with no type". What should I do instead?
@1Naif
@1Naif 7 жыл бұрын
Awesome man.. Please make a video about "templates" and how to use them in header file.
@danielconde001
@danielconde001 6 жыл бұрын
how bout operator[] ? not sure how that works
@slaincow4032
@slaincow4032 7 жыл бұрын
After the end of this series and the covering C++, can we get tutorials on a framework such as SDL or OpenGL? Or maybe something insanely new like Vulkan
@DridriLaBastos
@DridriLaBastos 6 жыл бұрын
With C++ you may prefer SFML rather than SDL
@shockminerx1518
@shockminerx1518 4 жыл бұрын
@@DridriLaBastos why?
@iamjovani
@iamjovani 7 жыл бұрын
Can the "
@MCLeo38638
@MCLeo38638 7 жыл бұрын
8:15
@sasoyu8922
@sasoyu8922 4 жыл бұрын
Great job! You could also say that some operators can't be overloaded 😉 (like the sizeof)
@Yupppi
@Yupppi 9 ай бұрын
I'm actually slightly confused as to why we have the need to make these operators. Like it looks like we're just saying the same operation inside the struct method, like "position + speed" -> "coordinate + other.coordinate" - I don't see what it does differently to what was said. Also I'm not sure if I understand what we're doing, I was thinking we should multiply the speed by time to get the added position, unless our speed is actually in discreet chunks, i.e. normalized to constant time and making it directly a distance value. In any case they're two float numbers, why can't they be added without saying + means +? Because they have two values and the compiler doesn't understand what you want to add together, the x+y parameters in the position or x parameters between position and speed? Now I actually think this is a fantastic way to extend my personal math program for school work with vector addition and multiplication, I was actually just last night pondering about how to go on about it when you have things like dot and cross products.
@Anonymous-wd1dk
@Anonymous-wd1dk 3 жыл бұрын
Hey cherno! I'm Going to be honest with you. I thought that this series is not that good and i couldn't understand anything and thought it was trash. But after looking at other series and courses, i can say that this is the best series to learn C++!
@pradhyuman6483
@pradhyuman6483 3 жыл бұрын
You can also watch the new Boston(bucky's c++) and apna college although cherno is also one of the best !(also it depends which one you prefer this guy is great too)
@TheSexGod
@TheSexGod 4 жыл бұрын
At 7:32 will line 40 know to multiply first and then add? Does overriding the + and * symbol keep the order of operations?
@Erebus2075
@Erebus2075 5 жыл бұрын
awesome
@zch7491
@zch7491 4 жыл бұрын
lol @ the boost reference
@elmosco593
@elmosco593 Жыл бұрын
Once you open a Cherno's video, first thing first, speed: 0.75.
@landwonder1676
@landwonder1676 2 жыл бұрын
Could someone help me with this question? After overloading, what is the order of the Arithmetic Operatoration. Does "*" still have higher priority than "+"? and Why?
@mikeyo5154
@mikeyo5154 2 жыл бұрын
I was thinking the same thing. I dont know the answer but was someone did
@mikeyo5154
@mikeyo5154 2 жыл бұрын
hoping someone did
@madness9509
@madness9509 2 жыл бұрын
Did anyone else need to make the ostream operator a friend function? That was the only way I could get it to work cause I would keep getting the error "Too may parameters for overloaded function".
@avi12
@avi12 4 жыл бұрын
0:36 Actually,
@mlecz
@mlecz 4 жыл бұрын
The operator's core of ' stream extraction / extraction operator). In the case of this video, the MAIN context is overloading the operators and their generalized implementation , not strict talking about IOSTREAM. Consequently, the notion used by Cherno is as correct as possible. Remember that IOSTREAM is just a library that you can include or not. Operators are in a different league. It's like class, namespace, int, float, template base etc. This is one of the foundations of language, with which things like IOSTREAM are built.
@jeejee4280
@jeejee4280 3 жыл бұрын
Actually Actually > is the extraction operator which works with std::cin.
@mlecz
@mlecz 3 жыл бұрын
@@jeejee4280 Yes, if we talk in context of IOSTREAM, then we call > as the extraction operator.
@jacobcline6892
@jacobcline6892 4 жыл бұрын
So the operator overloads only apply to things done with Vector2 but nothing else? And what's this "other" thing he keeps passing? I don't see any passing going on but his functions have parameters. Does thing1 become the "other" that is passed in something like: thing1 + thing2 ?
@marce3893
@marce3893 4 жыл бұрын
At 5:57 (and later at 11:09), is it okay to have a method call another one instead of doing the job itself in terms of performance? Is the assembly code exactly the same or?
@TheMR-777
@TheMR-777 4 жыл бұрын
Yes, your point is valid, I'm thinking the same. It'll be better Performance-wise. But to increase the functionality, and flexibility of the class, he did that. It's not always recommended. - If you're making a program for yourself, then do what you said. - If you're designing a Library, then do what Cherno did. It all depends.
@marce3893
@marce3893 4 жыл бұрын
@@TheMR-777 yeah I would never do that. but I was wondering if the compiler is smart enough to automatically optimize the code by "reducing" two (almost) immediate context switches directly into one
@TheMR-777
@TheMR-777 4 жыл бұрын
@@marce3893 If you are using the *Release Mode* , then most probably it would do that (what you are saying). Because, in *Release Mode* , Compiler always finds the best way (I mean, the shortest way) possible to optimize your code, in terms of Memory, and Code length. Your point is valid, Yes it's possible.
@ko95
@ko95 4 жыл бұрын
operator = function, neat!
The "this" keyword in C++
6:08
The Cherno
Рет қаралды 249 М.
Harder Than It Seems? 5 Minute Timer in C++
20:10
The Cherno
Рет қаралды 163 М.
1,000 Diamonds! (Funny Minecraft Animation) #shorts #cartoon
00:31
toonz CRAFT
Рет қаралды 39 МЛН
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 28 МЛН
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 10 МЛН
The purest coding style, where bugs are near impossible
10:25
Coderized
Рет қаралды 932 М.
Stack vs Heap Memory in C++
19:31
The Cherno
Рет қаралды 560 М.
Water powered timers hidden in public restrooms
13:12
Steve Mould
Рет қаралды 736 М.
lvalues and rvalues in C++
14:13
The Cherno
Рет қаралды 308 М.
10 Math Concepts for Programmers
9:32
Fireship
Рет қаралды 1,8 МЛН
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 293 М.
Rust Functions Are Weird (But Be Glad)
19:52
Logan Smith
Рет қаралды 131 М.
1,000 Diamonds! (Funny Minecraft Animation) #shorts #cartoon
00:31
toonz CRAFT
Рет қаралды 39 МЛН