OPERATORS and OPERATOR OVERLOADING in C++

OPERATORS and OPERATOR OVERLOADING in C++

The Cherno

6 лет назад

362,072 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Yuppi
Yuppi - 05.11.2023 16:39

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.

Ответить
L S
L S - 31.10.2023 18:59

Taking my first programming class and this series has been really helpful. Thank you.

Ответить
Tommy Snow
Tommy Snow - 11.10.2023 05:36

i can't believe that this is free.

Ответить
FIRE NUB
FIRE NUB - 10.10.2023 05:09

the fck cant understand a thing

Ответить
cheesecake
cheesecake - 08.10.2023 05:17

Why use this concept though, what is the real world application.

Ответить
Josalyn Rushton
Josalyn Rushton - 13.09.2023 04:46

Thank you this helped operator overloading click

Ответить
Rudy Fisher Author
Rudy Fisher Author - 01.09.2023 17:43

I'd be interested in a video about move assignment, copy assignment, assign by reference operators.

Ответить
Tomi Tomi
Tomi Tomi - 10.08.2023 17:00

Man, you are amazing, thank you a lot for your videos.

Ответить
Turdle
Turdle - 02.08.2023 05:16

print to the conzuuuuuul

Ответить
少不入川
少不入川 - 27.07.2023 21:07

难点:cout << vector2(二维向量)

Ответить
Iva Emply
Iva Emply - 23.07.2023 21:53

you are way to fast and not clear

Ответить
David Thwaites
David Thwaites - 27.06.2023 17:23

Wonderful explanation! Truly truly wonderful explanation of a pretty tricky concept to get your head around initially. Now it all makes sense.

Ответить
tim white
tim white - 09.06.2023 03:04

I realize you know your "stuff" but your teaching style comes across more like you're trying to impress us with your skill, and you are, but less like you care if those of us not nearly on your level leave with anymore than when we clicked on your tutorial. Anyway, thanks for the effort but the way you fly through your demos makes me think I need to find a tutor who talks as slowly as I comprehend.

Ответить
FoxholeWilly
FoxholeWilly - 22.05.2023 17:32

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.

Ответить
Niklas
Niklas - 18.05.2023 23:38

Why is cout << result 2 not working by default?😅I am pretty new to programming sry.

Ответить
Harry Heck
Harry Heck - 10.05.2023 18:34

I can't seem to wrap my mind around how position "gets into" the add function. I understand they we're accessing add, and that add takes in speed, and that add returns a new Vector2, but I'm not understanding exactly how position "gets into" the function. Is this just one of those "that's how the code works" kind of things? I understand stuff like .length() returns a length, but this one is confusing

Ответить
B
B - 23.04.2023 19:51

Bro what?

Ответить
Nishat Munshi
Nishat Munshi - 11.04.2023 06:20

very informative
thank you a lot

Ответить
Huiyen
Huiyen - 04.03.2023 05:56

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?

Ответить
Arpita Halder
Arpita Halder - 02.03.2023 22:23

am I the only one who listens him in 0.75 speed

Ответить
N N
N N - 14.02.2023 07:39

not string like ....thinking ... like me LOL

Ответить
Furkan Erdoğan
Furkan Erdoğan - 10.02.2023 18:11

while watching this video i understand this video isnt for begginers like me
:)

Ответить
Phantom
Phantom - 07.01.2023 16:23

Operators are functions and they make code look better.

Ответить
El Mosco
El Mosco - 05.12.2022 01:19

Once you open a Cherno's video, first thing first, speed: 0.75.

Ответить
Thadnill
Thadnill - 01.12.2022 18:57

I have to ask, what is the meaning when you write " :x(x), y(y) {} before the body of a function? is it a faster way to declare the variables?

Ответить
wtflol
wtflol - 21.11.2022 12:52

amazing

Ответить
Serkan Öztürk
Serkan Öztürk - 09.11.2022 13:12

Personal Notes:
- well understood

Ответить
Aarushi Agarwal
Aarushi Agarwal - 28.10.2022 13:20

It was really an informative video.Thanks Cherno😀

Ответить
Misha Luna
Misha Luna - 27.10.2022 02:47

gahdamn bro I love you but you talked way too fast in these videos hahah

Ответить
Hugo Almeida
Hugo Almeida - 27.08.2022 04:38

This series is FABULOUS Cherno! You've clarified all of my doubts, thank u buddy =D

Ответить
Patrick Mayer
Patrick Mayer - 18.08.2022 22:48

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!

Ответить
Benjamin Birchman
Benjamin Birchman - 15.08.2022 21:03

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!

Ответить
Michael Swahla
Michael Swahla - 15.08.2022 03:20

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__).

Ответить
HANYU ZHANG
HANYU ZHANG - 26.06.2022 23:17

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.

Ответить
Uttam Kushwah
Uttam Kushwah - 24.05.2022 08:23

"What are you doing" stares hard LOL😆

Ответить
Amitkumar Pal
Amitkumar Pal - 18.05.2022 05:05

I think you can beat eminem in rap

Ответить
Geo Brell
Geo Brell - 09.05.2022 12:43

can someone explain how he navigates through his code so fast? he selects, copies and pastes code so fast?

Ответить
Niket Sharma
Niket Sharma - 05.05.2022 21:26

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.

Ответить
Ece Akdeniz
Ece Akdeniz - 28.04.2022 18:56

i thought we have operator overloading in java too?

Ответить
Li Jacky
Li Jacky - 25.04.2022 19:51

Love u!

Ответить
Land Wonder
Land Wonder - 14.04.2022 17:52

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?

Ответить
Sol
Sol - 25.03.2022 01:49

Learning this in my CS class kinda made me die inside. I was able to understand you much more easily, thank you!

Ответить
joe reinold
joe reinold - 13.03.2022 21:57

Can you ID an IDE that would highlight overloaded operators, such as color coding. It does make easier to read the code.

Ответить
Ezzy GD
Ezzy GD - 11.03.2022 21:49

I'm pretty late to the party here, but can someone explain to me what does "doesn't modify the class" mean? What is a case in which a function would modify the class it belongs to?

Ответить