Operator Overloading

preview_player
Показать описание
In this video, I take a simple look at operator overloading in C++, and implement a 2D vector type. I then turn this type into a template to accommodate different precision requirements.

Twitter: @javidx9
Twitch: javidx9
Рекомендации по теме
Комментарии
Автор

Hello! Due to some IRL things happening, this video is a bit rushed, and it shows (sorry!). Firstly, there is a bug regarding the array subscript operator i used a "1" instead of an 'i' (clearly need new glasses). Secondly I omitted references on the scalar arguments for "*=" operators - this doesn't actually matter from a functional point of view, but it is potentially more optimal. Finally, the properties are initialised to "0.0f" instead of just "0". Again, this doesn't matter, but the compiler may grumble. Regardless, the code in the github link above is corrected.

javidx
Автор

After 5 years this is literally the best video explaining operator overloading on youtube! thank you javidx9!!!

mohamedadel
Автор

Formatting was a nice final touch 🤝🏻
P.S. Visual Studio like almost any other IDE supports multi-caret editing, so you can
-> select “float”
-> 1) add the new caret to the next occurrence [Shift-Alt-. In VS] * n times until everything needed is selected or 2) even select all of them in the file [Shift+Alt+;]
-> replace in one turn

VRchitecture
Автор

For another video:

I have never learned from anyone apart from myself how to use a debugger.
Breakpoints, stepping, over, into, out of etc. call stack – the works. Maybe even output at specific points, how to use it well.

I think for beginners this could be a valuable video as most will probably encounter something that compiles, but doesn’t do what it should.

joshinils
Автор

I'm a simple man. I see a javidx9 video, I click.

satainter
Автор

17:38 But, javidx9! You're both useful and pretty :D.

Cheers for the great video.

mbabb
Автор

What? A new video on a part of C++ that I don't use enough but definitely need to??!? Yes please!

Thank you, Javid!

Vixikats
Автор

For some reason your videos trigger ASMR. Been watching all of them for the last couple of weeks and I really enjoy them. Very relaxing.

Fergobirck
Автор

I am still learning C++, I did understand what you wrote in code although I haven't touched upon Templates or the typedef thing yet. Was searching for Operator Overloading videos and came here 'cause I knew I'd find a pretty epic explanation, and you delivered.

This feels, very beautiful!! Never thought C++ would feel that impressive. I actually genuinely got a motivation boost to continue learning more C++, it just seems unimaginably flexible and performant!!

Oh man and that "tidying".. :D

mostafamagdy
Автор

My favorite programmer on YouTube. Thank you javidx9!

Tneo
Автор

Very nice. I can't get enough of those operator overloads, which are easily one of the most useful things I have ever used.
Though your approach only work for structs. If anyone is thinking in implementing this to classes, you'll have to use the 'friend' keyword to make private members visible to that operation.

jimjohn
Автор

Best explanation about Operator Overloading i have ever seen. Never really understood it well. Your explanation made it much more clear. Thanks!!

PersonalJGRM
Автор

This is a great video and shows more in depth of what I learned in University. Thank you for sharing your knowledge Javidx9

jburtish
Автор

Great video and explanation Javidx9, I've tried overloading operators before and was struggeling big time, but you make it sound so easy, I understood everything, great teacher, thank you

YoungOrbital
Автор

After this having a better understanding of C++ I can enjoy your videos more and actually understand what you are showing! This video is super helpful right now.

NeZversSounds
Автор

bro you're literally one of my favorite people on youtube

alecmather
Автор

Hey javidx9
I have been following your channel for the last year or so, and I always find your videos interesting and something to look forward to.
The way you introduce different concepts, being both light and charming as well as thorough enough to be useful, is an absolute delight.
You are doing a great job, and I hope you keep it up! :)
Best regards, from Denmark.

uabanur
Автор

@2:27 That x(_x) kinda looks like me (a newbie) staring at the many C++ tutorials I'm viewing.
The y(_y) is me when I realize I spent 1hr debugging an error caused by an extra semicolon.

Thanks, Javid! Overloading is so freaking amazing, I don't know if it's a standard feature in rich programming languages or a C++ thing, but it's so powerful!

leerv.
Автор

I'm creating my own 2D math library (just for fun) and later implement it for my game. I'm only 14 but I like learning to programme a lot. Thanks to you, too!

clodgozon
Автор

16:24 what is that magic! That can't be a legal move, right? How do you do that?

Ragazz