C++ Operator Overloading beginner to advanced (in-depth explanation)

  Рет қаралды 247,910

CodeBeauty

CodeBeauty

Күн бұрын

📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.
Download Visual Assist here: bit.ly/WT-CB
I use it to enhance the performance, features, and support for C, C#, and C++ development in Visual Studio.
Download Ultra Edit here: bit.ly/UE_CB
It is a powerful, secure text editor designed specifically for programmers.
In this video, I'll explain C++ Operator Overloading from beginner to advanced and teach you about operator functions.
In C++ overloaded operators are functions with special names: the keyword "operator" followed by the symbol for the operator being defined (ex. operator+, operator-, operator==, etc.)
Which operators can be overloaded?
- Most operators can be overloaded, the exceptions are . (dot) :: ?: sizeof
There are two types of operator functions: global operator functions and member operator functions.
In the video, I'll teach you about both and I'll also demonstrate how to do operator overloading for the most important operators and explain common errors that happen with operator overloading
🎁 Download PVS-Studio for free with #code_beauty promo code: bit.ly/PVS-StudioFreeCB1
▶️ PVS-Studio KZfaq channel - / @pvsstudio_channel
🇫 PVS-Studio Facebook group - / staticcodeanalyzer
☕ If you've found my content helpful and would like to support me, you now have the option to buy me a coffee or a cookie! It's a small gesture of gratitude that means a lot to me and helps me keep creating free educational videos for you. Use the link to make a contribution: bit.ly/CodeBeauty_BuyMeACoffee
However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇
C++ Structures - • C++ Structures for beg...
C++ Classes and constructors - • C++ OOP - Introduction...
Contents:
00:00 - Intro
01:01 - This is how I analyze my code
01:54 - Introduction to operator overloading and operator functions in C++
07:29 - Ostream operator overloading (insertion operator)
18:12 - Overloading += operator
21:35 - Different types of operator functions (global vs member functions)
23:57 - Ostream operator overloading (insertion operator)
26:57 - Overloading -= operator
28:34 - C++ operator overloading common errors
34:16 - Results of the PVS-Studio code analysis
Follow me on other platforms:
Instagram 📸 - / truecodebeauty
Twitter 🐦- / truecodebeauty
******CODE IS IN THE COMMENTS******

Пікірлер: 412
@CodeBeauty
@CodeBeauty 3 жыл бұрын
📚 Learn how to solve problems and build projects with these Free E-Books ⬇️ C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook 🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/ Experience the power of practical learning, gain career-ready skills, and start building real applications! This is a step-by-step course designed to take you from beginner to expert in no time! 💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10). Use it quickly, because it will be available for a limited time. #include #include #include using namespace std; struct KZfaqChannel { string Name; int SubscribersCount; KZfaqChannel(string name, int subscribersCount) { Name = name; SubscribersCount = subscribersCount; } bool operator==(const KZfaqChannel&channel) const{ return this->Name == channel.Name; } }; ostream& operator
@hbm293
@hbm293 3 жыл бұрын
For the KZfaqChannel::operator==() you may first check whether (this == channel) so that you know it's the same object (comparing the object to itself) and can skip any other sort of member-equality checks.
@hbm293
@hbm293 3 жыл бұрын
It should also be noted that, here you have chosen the simple case where you use a struct, so all its members are public. When a class is used with private or protected members, you'll need to tell the class that these overloaded global operators are "friend" of the class.
@parthmakode5255
@parthmakode5255 3 жыл бұрын
please tell why we cant print yt1 and yt2 in the same line ?i know you have explained how to fix it but the reason why we cant do that isn't there . Could you post any link where this issue has been discussed?cause when I searched i got nothing
@hbm293
@hbm293 3 жыл бұрын
@@parthmakode5255 Do you mean printing them in the same line of code? or?
@parthmakode5255
@parthmakode5255 3 жыл бұрын
@@hbm293 yup, in the same line of code
@matijaxzivkovic8843
@matijaxzivkovic8843 3 жыл бұрын
We all loves this girl. She is amazing!
@CodeBeauty
@CodeBeauty 3 жыл бұрын
Thank you! 😄😄
@tactlesscloud2784
@tactlesscloud2784 2 жыл бұрын
You somehow got me to understand a concept in 30 minutes where my professor couldn't for a whole semester thank you so much for the videos. They're really carrying me through college!
@remimonsel9944
@remimonsel9944 Жыл бұрын
I spend hours watching your videos and every times I say "ohhhh that's why". You can't imagine how many times you explain me things that others never succeeded in teaching me.
@ghazanfarghaffar1249
@ghazanfarghaffar1249 Ай бұрын
didn't expect a woman explaining operator overloading flawlessly. (thankyou)
@CodeBeauty
@CodeBeauty Ай бұрын
🥰🥰
@user-mt8wp7ft6z
@user-mt8wp7ft6z 3 жыл бұрын
It's at the midnight , a.m. 30,in Taiwan, and I will look this video in the morning!
@CodeBeauty
@CodeBeauty 3 жыл бұрын
Good night! 😴💤
@chriscarlin3972
@chriscarlin3972 3 жыл бұрын
I haven't used c++ in years and these videos make for a great refresher on how things work. Also love when she says the work parameters
@satvrii
@satvrii Жыл бұрын
We can never get bored in your lectures! Your way of teaching is fab 😊
@jassielitu
@jassielitu Жыл бұрын
Every seconds I watched, I learnt something new. Wonder how many more good people we have in this world. Thanks a lot!
@deveshsingh3237
@deveshsingh3237 Жыл бұрын
I watched so many videos on operator overloading, and i can confidently say this is hands down the **BEST** video on this topc, thank you so much for explaining it this clearly. made my day
@arianevigested1625
@arianevigested1625 2 жыл бұрын
Thank you so much for this! Our professor ran low on time when it came to describing operator overloading, and this video has helped me understand a bit better what to expect. Test next week and I feel a bit better prepared after watching a few of your videos!
@klasr5837
@klasr5837 3 жыл бұрын
Thank you saldina
@CodeBeauty
@CodeBeauty 3 жыл бұрын
You are so welcome! ❤️♥️❤️
@kutch2426
@kutch2426 2 жыл бұрын
This video was golden. I had struggled with this specific topic for quite a long time, and this explanation was perfect. Thank you!!
@claritydive
@claritydive Жыл бұрын
I've been studying computer science for almost 3 years and this is the first time I've truly understood this. Thank you.
@barshachaudhary982
@barshachaudhary982 4 ай бұрын
So far the best video I have found for operator overloading
@aesthetic.__.writes8885
@aesthetic.__.writes8885 5 ай бұрын
Tommarow is my final term paper so I am so confused about operator overloading but after watching this video , now I so comfident... Thanks Mam your effort is priceless the way you teach programming is very amazing...Thanks for helping us. Big respect from pakistan..
@codymetz8689
@codymetz8689 2 жыл бұрын
great video. In my class that i'm taking, all the ostream overload examples specified the data type beforehand. Seeing the conflicts that come with overloading with a void function that you showed helped with making sense of it.
@siddharthpawar552
@siddharthpawar552 3 жыл бұрын
You come up exactly with the topic that i look forward to learn. 😄🤘
@CodeBeauty
@CodeBeauty 3 жыл бұрын
Glad to hear it! 😄😄
@codystar3669
@codystar3669 3 жыл бұрын
I also shared this type of video Please visit and seee ♥️ Thankyou for listening ✨ #seriescplusplus
@macko7177
@macko7177 2 жыл бұрын
Well explained! She deserves a lot of credit. Subscribed!
@abimediae5790
@abimediae5790 Жыл бұрын
You are exceptional coder; you made the concept so clear. Thank you.
@DON9307
@DON9307 Жыл бұрын
You gave a great explanation of operator overloading. I especially appreciated the explanation of the errors at the end for the -= operator.
@gautamgandotra9965
@gautamgandotra9965 Жыл бұрын
best video till now on operator overloading thank you.
@Rsdawg5519
@Rsdawg5519 Жыл бұрын
This video was absolutely great! I coded along with you and that made it so much easier to understand! Your teaching is excellent!
@zahidgul5811
@zahidgul5811 2 жыл бұрын
what an explanation. It have not seen on youtube, who can better explain than this. Thanks for taking your time to provide with such great videos.
@likami6830
@likami6830 2 жыл бұрын
I've started learning from you when I'd looked for tutorial about maps but now I just can't stop studying different topics I discovered here. Programming became such a cool thing for me. I always find something new, see old topics in a new light and it's such a feeling... thank you so much!!! This June is amasing because of you^^
@CodeBeauty
@CodeBeauty 2 жыл бұрын
Thanks for this comment, it made my day. I'm so happy for you 🤞☺️🥰
@874D8
@874D8 4 ай бұрын
Thank you! very helpful!
@mexxiano
@mexxiano 3 жыл бұрын
Wonderful! Awaiting for this very interesting topic! Thank you!!!
@CodeBeauty
@CodeBeauty 3 жыл бұрын
You're most welcome! Hope you enjoyed it! ❣️❣️
@maxbretschneider6521
@maxbretschneider6521 Жыл бұрын
Great explanation, thanks!
@oatie4262
@oatie4262 2 жыл бұрын
Thanks very much for articulating the concept so clearly! I also appreciated that you explained (23:18) why, when overloading the
@orangindodinewzealand8038
@orangindodinewzealand8038 2 жыл бұрын
in my "opinion", she needed to pass the value of yt1 which has the name and subscribers and also needed to pass the ostream datatype in order for the function to know what is the value (could be "cout" or "cin" or anything), unlike the += she just need to pass the yt1 to be added later in mycollection list, and she called a "method(which is from the operator +=)" in mycollection(which the list is already within the scope, you just need to access from it) to behave(which is push_back the yt1 to the list) so basically, she just needed to pass yt1. *correct me if im wrong
@sakshamdogra
@sakshamdogra Жыл бұрын
Finally somone who explains with simplicity❤️
@duesenberger
@duesenberger 3 жыл бұрын
Very helpful! Great step by step inroduction.
@technologyrealmresources
@technologyrealmresources 5 ай бұрын
Amazing video, thank you!
@flaviocampos3581
@flaviocampos3581 Жыл бұрын
You got a sub. I watched another video about this got a little bit confused... but now is as clear as water. Thank you.
@aryanverma6261
@aryanverma6261 Жыл бұрын
Best tutorial on KZfaq!
@anxonpues6018
@anxonpues6018 8 ай бұрын
good examples, explanation rich and at the saame time easy would try to remember all
@hussainaqeel7371
@hussainaqeel7371 3 жыл бұрын
Hey Saldina! Great video! Thank you gor all the content you create! I wanted to ask if you had a video on working with memory allocation etc on C/C++?
@venkatsai817
@venkatsai817 2 жыл бұрын
Thanks for such an indepth explanation of operator overloading concept .I have a clear clarity on all oops concepts . It really helps in my job interviews and stuff.
@giftkuzwayo3077
@giftkuzwayo3077 8 ай бұрын
Literally saving my career. Thank You soo much!!!
@user-cn6hw5lu5s
@user-cn6hw5lu5s 3 жыл бұрын
Thumbs up, thank you very much!
@CodeBeauty
@CodeBeauty 3 жыл бұрын
You are so welcome! ❤️♥️❤️
@kailas813
@kailas813 Жыл бұрын
Really this video helps a lot to understand the complete picture of the operator overloading concept. Thank you.
@docsduarte1999
@docsduarte1999 Жыл бұрын
Thank you soo much, I had a lot of fun learning with your video. Very interesting.
@LymariArzola
@LymariArzola 2 жыл бұрын
This was an amazing tutorial. Thank you!
@prashantkumarsharma2306
@prashantkumarsharma2306 2 жыл бұрын
WOW!!! You make things so simple !!!
@sonetadhikary675
@sonetadhikary675 Жыл бұрын
oNE OF THE BEST VIDEO ON OPERATOR OVERLOADING IN KZfaq.
@Ijamhuang
@Ijamhuang 2 жыл бұрын
good video for c++ tutorial~ thanks a lot
@malatini_ytb
@malatini_ytb 2 жыл бұрын
You're the best !! Thanks a lot for this video !
@Max-uk3kr
@Max-uk3kr 2 жыл бұрын
Great video, definitely gave me a better understanding of overloading operators.
@drulli1
@drulli1 6 ай бұрын
Great tutorial, as always. You are awesome! 🤗
@morshedraiankhan6968
@morshedraiankhan6968 Жыл бұрын
Finally understood the concept of operator overloading. Thank you.
@erikchen6883
@erikchen6883 2 жыл бұрын
Thank you. You are awesome, CodeBeauty! Very knowledgable and able to articulate C++ terms and concepts!
@arpitgupta1765
@arpitgupta1765 Жыл бұрын
Best explantion I could find for Operator Overloading :)
@MCBREDL
@MCBREDL Жыл бұрын
very well explained thanks a lot. saved me a lot of time to understand overloading.
@bhimbdrlama
@bhimbdrlama 2 жыл бұрын
This topic gave a headach.. but the way you explain..I really gave me a relief.
@dianelysrocha7156
@dianelysrocha7156 3 жыл бұрын
This is so cool!!
@muhammadumair6554
@muhammadumair6554 3 жыл бұрын
Waiting!!! I hope that's gonna be another fantastic video❣️
@CodeBeauty
@CodeBeauty 3 жыл бұрын
Hope you enjoyed it! ❣️❣️
@muhammadumair6554
@muhammadumair6554 3 жыл бұрын
@@CodeBeauty Surely, you are ❣️
@codystar3669
@codystar3669 3 жыл бұрын
I also shared this type of video Please visit and seee ♥️ Thankyou for listening ✨ #seriescplusplus
@RaverBorn
@RaverBorn 2 жыл бұрын
Another awesome video! Thank you!
@ahmedmontasser1248
@ahmedmontasser1248 Жыл бұрын
Best instructor,,, thanks for the detailed explanation.
@jolly_dollyyy
@jolly_dollyyy 2 жыл бұрын
surreal explanation ❤ ma'am hats off!!😊
@alexfrozen
@alexfrozen Жыл бұрын
Thank you! Amazing)
@learnwithme7750
@learnwithme7750 2 жыл бұрын
Wow!! What an amazing video this is!! I enjoyed every second of this video about operator overloading... Thanks Saldina for wonderful explanation...
@OnPoint760
@OnPoint760 Жыл бұрын
thank you for breaking it down. great video
@stevenkarrer1113
@stevenkarrer1113 Жыл бұрын
very good, thank you alot!
@Ghisisan_
@Ghisisan_ 3 жыл бұрын
A very fine video, indeed. Thanks! 😊
@CodeBeauty
@CodeBeauty 3 жыл бұрын
Glad you enjoyed it! 😊❤️❤️
@fusion1388
@fusion1388 2 жыл бұрын
Best Explanation Ever 👍
@anshulbansal8828
@anshulbansal8828 3 жыл бұрын
every minute of this video is worth it, thankyou beauty to help us enhance our coding skills... I love the way how small and side error cases you taught with so much simplicity, I have done 2 DSA courses till now, they had never given any importance to Operator Overloading, just taught the syntax, told this is overloading, enjoy students!
@CodeBeauty
@CodeBeauty 3 жыл бұрын
Thank you Anshul 🤗☺️🥰
@tom46dude
@tom46dude Жыл бұрын
I agree. Best explanation of Operator Overloading ever.
@SaidBADDAG
@SaidBADDAG 2 жыл бұрын
Thank you so much, it's really helpfull
@sydwellnkhabela387
@sydwellnkhabela387 3 жыл бұрын
you are amazing. With the covid 19 currently high in South Africa. i can safely stay at home and learn from your videos. I'm looking forward towards your new content
@itstrue3490
@itstrue3490 2 жыл бұрын
I really appreciate your deep explanation about concepts.....and thank you so so much
@gisellemusa4403
@gisellemusa4403 2 жыл бұрын
your explainations are perfect !!
@TejasDhule
@TejasDhule 2 жыл бұрын
You Are Just Amazing!
@-_-5070
@-_-5070 2 жыл бұрын
You're just amazing 💗
@tayyabamir8767
@tayyabamir8767 3 жыл бұрын
Your videos helped me alot in learning , very much interesting.
@thirstforknowledge7634
@thirstforknowledge7634 3 жыл бұрын
Thank you very much for making this amazing video !!
@shendoo2020
@shendoo2020 2 жыл бұрын
Thank you, This video is very helpful to understand operators override.
@phil86_
@phil86_ 2 жыл бұрын
Fantastic tutorial
@macxenixg.oblimar4527
@macxenixg.oblimar4527 2 жыл бұрын
Thank you !
@powerpoint444
@powerpoint444 Жыл бұрын
The best tuturial on YT
@mradneer7915
@mradneer7915 Жыл бұрын
We thank you for your tremendous efforts. Please persevere
@muhammedmame8980
@muhammedmame8980 Жыл бұрын
it is great thank you so much I loved it, you are amazing
@dileepbokka5525
@dileepbokka5525 2 жыл бұрын
Thank you , excellent teaching Madam
@devman8119
@devman8119 3 жыл бұрын
Thanks for the video and Please continue the linked list lectures. Thank you🙂
@lucid-louisfromouterspace6918
@lucid-louisfromouterspace6918 3 жыл бұрын
Amazing. I am struggling in a college program in OOP. CodeBeauty is the way i can keep my high score, everything my teacher teaches bad, Saldina explains it perfectly. Today was operator overloading in class and i was stucked. Like a miracle, this video appears. I can solve my homework because of that. Thousands thank you Saldina. May i ask a tuto about the friend function, for my next class? Thank you sooooo much!
@nikhielsingh748
@nikhielsingh748 2 жыл бұрын
best video EVER !!!
@kasimsche2812
@kasimsche2812 3 жыл бұрын
She is sooooo amazing, very confident and very precise, perfect. 👌🏻👌🏻👌🏻💯💯💯❤❤❤
@refikalpertuncer8512
@refikalpertuncer8512 3 жыл бұрын
Well explained. Good content, definetely.
@mrcrypto.1064
@mrcrypto.1064 3 жыл бұрын
I have learned sooo much from you. Think you.
@CodeBeauty
@CodeBeauty 3 жыл бұрын
You are welcome! 😃😃🥰
@abeerkh8941
@abeerkh8941 2 жыл бұрын
It's so helpful, Thank you very much...
@Shadow-lx9rh
@Shadow-lx9rh 2 жыл бұрын
Thank you soo much whatever u spoke was very much understandable ,each and every part of it made me understand the code even more in dept. A heartfelt thanks🙏
@majdijaiel6668
@majdijaiel6668 3 жыл бұрын
I love How you explain things, please make more videos about this same topic PLEASE
@sonwabomakinana7962
@sonwabomakinana7962 2 жыл бұрын
You make c++ understanding and mastering so simple 🙌🙌🙌 appreciated in south africa 🇿🇦🇿🇦🇿🇦
@ferfykins
@ferfykins Ай бұрын
Excellent video, ty so much!!
@CodeBeauty
@CodeBeauty Ай бұрын
You're welcome 🥰
@TEONSANouhourou
@TEONSANouhourou Жыл бұрын
Best explanation ever!!! Hope to see tutorials about Design Patterns in C++ on your channel.
@NilavarsanManimaran
@NilavarsanManimaran 4 ай бұрын
This is the best explanation that i have ever seen so far, taking consideration of all the domains in c++.
@NilavarsanManimaran
@NilavarsanManimaran 4 ай бұрын
i am a 3rd year student, any i have learned java, python, js etc.. but c++ attracted the most of all, can u suggest some domains in c++, so that i can get easy interns.
@granumuse7847
@granumuse7847 3 жыл бұрын
cout
@CodeBeauty
@CodeBeauty 3 жыл бұрын
Great that you're trying to figure it out on your own 😄
@careerspack
@careerspack 3 жыл бұрын
The hottest coder online. One more reason to study coding.
@mba2ceo
@mba2ceo 2 жыл бұрын
She is BEST teacher I EVER had ... but I still feel inept. Thank U !!!
@sanjishmaharjan557
@sanjishmaharjan557 3 жыл бұрын
You are a great teacher. lots of love❤
@swayam50
@swayam50 3 жыл бұрын
Thanks for this amazing explanation ❤️
@SharuxD
@SharuxD Жыл бұрын
I am speechless Amazing Explanation
@tausifhossain8634
@tausifhossain8634 2 жыл бұрын
I was struggling to understand this topic thank you so much for letting me understand.
Friend functions and classes in C++ (Programming for beginners)
18:18
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 12 МЛН
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 192 МЛН
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,7 МЛН
OPERATORS and OPERATOR OVERLOADING in C++
12:44
The Cherno
Рет қаралды 367 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 241 М.
SMART POINTERS in C++ (for beginners in 20 minutes)
24:32
CodeBeauty
Рет қаралды 97 М.
Why Isn't Functional Programming the Norm? - Richard Feldman
46:09
Bluetooth connected successfully 💯💯
0:16
Blue ice Comedy
Рет қаралды 1,3 МЛН
Копия iPhone с WildBerries
1:00
Wylsacom
Рет қаралды 8 МЛН
Мой новый мега монитор!🤯
1:00
Корнеич
Рет қаралды 244 М.
Частая ошибка геймеров? 😐 Dareu A710X
1:00
Вэйми
Рет қаралды 4,9 МЛН