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

  Переглядів 231,932

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.
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 Visual Assist here: bit.ly/VisualAssistDownload
(It improves Visual Studio experience by quickly identifying and fixing code errors)
🎁 Download PVS-Studio for free with #code_beauty promo code: bit.ly/PVS-StudioFreeCB1
▶️ PVS-Studio UKposts 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******

КОМЕНТАРІ: 396
@CodeBeauty
@CodeBeauty 2 роки тому
📚 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 UKpostsChannel { string Name; int SubscribersCount; UKpostsChannel(string name, int subscribersCount) { Name = name; SubscribersCount = subscribersCount; } bool operator==(const UKpostsChannel&channel) const{ return this->Name == channel.Name; } }; ostream& operator
@hbm293
@hbm293 2 роки тому
For the UKpostsChannel::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 2 роки тому
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 2 роки тому
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 2 роки тому
@@parthmakode5255 Do you mean printing them in the same line of code? or?
@parthmakode5255
@parthmakode5255 2 роки тому
@@hbm293 yup, in the same line of code
@matijaxzivkovic8843
@matijaxzivkovic8843 2 роки тому
We all loves this girl. She is amazing!
@CodeBeauty
@CodeBeauty 2 роки тому
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.
@aesthetic.__.writes8885
@aesthetic.__.writes8885 2 місяці тому
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..
@klasr5837
@klasr5837 2 роки тому
Thank you saldina
@CodeBeauty
@CodeBeauty 2 роки тому
You are so welcome! ❤️♥️❤️
@user-mt8wp7ft6z
@user-mt8wp7ft6z 2 роки тому
It's at the midnight , a.m. 30,in Taiwan, and I will look this video in the morning!
@CodeBeauty
@CodeBeauty 2 роки тому
Good night! 😴💤
@barshachaudhary982
@barshachaudhary982 Місяць тому
So far the best video I have found for operator overloading
@siddharthpawar552
@siddharthpawar552 2 роки тому
You come up exactly with the topic that i look forward to learn. 😄🤘
@CodeBeauty
@CodeBeauty 2 роки тому
Glad to hear it! 😄😄
@codystar3669
@codystar3669 2 роки тому
I also shared this type of video Please visit and seee ♥️ Thankyou for listening ✨ #seriescplusplus
@user-cn6hw5lu5s
@user-cn6hw5lu5s 2 роки тому
Thumbs up, thank you very much!
@CodeBeauty
@CodeBeauty 2 роки тому
You are so welcome! ❤️♥️❤️
@chriscarlin3972
@chriscarlin3972 2 роки тому
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 😊
@muhammadumair6554
@muhammadumair6554 2 роки тому
Waiting!!! I hope that's gonna be another fantastic video❣️
@CodeBeauty
@CodeBeauty 2 роки тому
Hope you enjoyed it! ❣️❣️
@muhammadumair6554
@muhammadumair6554 2 роки тому
@@CodeBeauty Surely, you are ❣️
@codystar3669
@codystar3669 2 роки тому
I also shared this type of video Please visit and seee ♥️ Thankyou for listening ✨ #seriescplusplus
@NilavarsanManimaran
@NilavarsanManimaran Місяць тому
This is the best explanation that i have ever seen so far, taking consideration of all the domains in c++.
@NilavarsanManimaran
@NilavarsanManimaran Місяць тому
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.
@abujamilfaisalshuvo9381
@abujamilfaisalshuvo9381 2 роки тому
watching from Bangladesh ma'am best teacher in youtube
@anshulbansal8828
@anshulbansal8828 2 роки тому
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 2 роки тому
Thank you Anshul 🤗☺️🥰
@tom46dude
@tom46dude Рік тому
I agree. Best explanation of Operator Overloading ever.
@DON9307
@DON9307 Рік тому
You gave a great explanation of operator overloading. I especially appreciated the explanation of the errors at the end for the -= operator.
@Ghisisan_
@Ghisisan_ 2 роки тому
A very fine video, indeed. Thanks! 😊
@CodeBeauty
@CodeBeauty 2 роки тому
Glad you enjoyed it! 😊❤️❤️
@jassielitu
@jassielitu Рік тому
Every seconds I watched, I learnt something new. Wonder how many more good people we have in this world. Thanks a lot!
@sakshamdogra
@sakshamdogra Рік тому
Finally somone who explains with simplicity❤️
@wscamel226
@wscamel226 10 місяців тому
6:56 - fine. You convinced me.
@mexxiano
@mexxiano 2 роки тому
Wonderful! Awaiting for this very interesting topic! Thank you!!!
@CodeBeauty
@CodeBeauty 2 роки тому
You're most welcome! Hope you enjoyed it! ❣️❣️
@granumuse7847
@granumuse7847 2 роки тому
cout
@CodeBeauty
@CodeBeauty 2 роки тому
Great that you're trying to figure it out on your own 😄
@gautamgandotra9965
@gautamgandotra9965 Рік тому
best video till now on operator overloading thank you.
@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!
@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!!
@mrcrypto.1064
@mrcrypto.1064 2 роки тому
I have learned sooo much from you. Think you.
@CodeBeauty
@CodeBeauty 2 роки тому
You are welcome! 😃😃🥰
@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.
@powerpoint444
@powerpoint444 Рік тому
The best tuturial on YT
@claritydive
@claritydive 11 місяців тому
I've been studying computer science for almost 3 years and this is the first time I've truly understood this. Thank you.
@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
@macko7177
@macko7177 2 роки тому
Well explained! She deserves a lot of credit. Subscribed!
@user-ng8rl3jb1i
@user-ng8rl3jb1i 6 місяців тому
i wish i ll become a programer like you someday. im preparing for my entrance exams in informatics and computer engineering and i have so much to do
@abimediae5790
@abimediae5790 Рік тому
You are exceptional coder; you made the concept so clear. 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!
@hussainaqeel7371
@hussainaqeel7371 2 роки тому
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++?
@LymariArzola
@LymariArzola 2 роки тому
This was an amazing tutorial. Thank you!
@OnPoint760
@OnPoint760 Рік тому
thank you for breaking it down. great video
@giftkuzwayo3077
@giftkuzwayo3077 5 місяців тому
Literally saving my career. Thank You soo much!!!
@arpitgupta1765
@arpitgupta1765 Рік тому
Best explantion I could find for Operator Overloading :)
@drulli1
@drulli1 3 місяці тому
Great tutorial, as always. You are awesome! 🤗
@874D8
@874D8 Місяць тому
Thank you! very helpful!
@kailas813
@kailas813 Рік тому
Really this video helps a lot to understand the complete picture of the operator overloading concept. Thank you.
@aryanverma6261
@aryanverma6261 Рік тому
Best tutorial on UKposts!
@Max-uk3kr
@Max-uk3kr 2 роки тому
Great video, definitely gave me a better understanding of overloading operators.
@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
@ahmedmontasser1248
@ahmedmontasser1248 Рік тому
Best instructor,,, thanks for the detailed explanation.
@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.
@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.
@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.
@SharuxD
@SharuxD Рік тому
I am speechless Amazing Explanation
@jolly_dollyyy
@jolly_dollyyy Рік тому
surreal explanation ❤ ma'am hats off!!😊
@prashantkumarsharma2306
@prashantkumarsharma2306 2 роки тому
WOW!!! You make things so simple !!!
@morshedraiankhan6968
@morshedraiankhan6968 Рік тому
Finally understood the concept of operator overloading. Thank you.
@duesenberger
@duesenberger 2 роки тому
Very helpful! Great step by step inroduction.
@devman8119
@devman8119 2 роки тому
Thanks for the video and Please continue the linked list lectures. Thank you🙂
@itstrue3490
@itstrue3490 2 роки тому
I really appreciate your deep explanation about concepts.....and thank you so so much
@MCBREDL
@MCBREDL 10 місяців тому
very well explained thanks a lot. saved me a lot of time to understand overloading.
@kasimsche2812
@kasimsche2812 2 роки тому
She is sooooo amazing, very confident and very precise, perfect. 👌🏻👌🏻👌🏻💯💯💯❤❤❤
@tausifhossain8634
@tausifhossain8634 Рік тому
I was struggling to understand this topic thank you so much for letting me understand.
@sonetadhikary675
@sonetadhikary675 Рік тому
oNE OF THE BEST VIDEO ON OPERATOR OVERLOADING IN UKposts.
@likami6830
@likami6830 Рік тому
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 Рік тому
Thanks for this comment, it made my day. I'm so happy for you 🤞☺️🥰
@majdijaiel6668
@majdijaiel6668 2 роки тому
I love How you explain things, please make more videos about this same topic PLEASE
@bhimbdrlama
@bhimbdrlama Рік тому
This topic gave a headach.. but the way you explain..I really gave me a relief.
@swayam50
@swayam50 2 роки тому
Thanks for this amazing explanation ❤️
@malatini_ytb
@malatini_ytb 2 роки тому
You're the best !! Thanks a lot for this video !
@technologyrealmresources
@technologyrealmresources 2 місяці тому
Amazing video, thank you!
@TheYuzy
@TheYuzy Рік тому
I was struggeling in this topic. After the video i fix my problem. Thank you ❤
@erikchen6883
@erikchen6883 2 роки тому
Thank you. You are awesome, CodeBeauty! Very knowledgable and able to articulate C++ terms and concepts!
@anxonpues6018
@anxonpues6018 5 місяців тому
good examples, explanation rich and at the saame time easy would try to remember all
@TEONSANouhourou
@TEONSANouhourou Рік тому
Best explanation ever!!! Hope to see tutorials about Design Patterns in C++ on your channel.
@gisellemusa4403
@gisellemusa4403 Рік тому
your explainations are perfect !!
@maxbretschneider6521
@maxbretschneider6521 Рік тому
Great explanation, thanks!
@Ijamhuang
@Ijamhuang 2 роки тому
good video for c++ tutorial~ thanks a lot
@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...
@jasnarmstrng
@jasnarmstrng Рік тому
"I was like ohhhhh, now I get it". Thanks, you made this language feature easy to understand.
@CodeBeauty
@CodeBeauty Рік тому
I'm glad my video helped you. 🥰❤️
@fusion1388
@fusion1388 Рік тому
Best Explanation Ever 👍
@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🙏
@mradneer7915
@mradneer7915 Рік тому
We thank you for your tremendous efforts. Please persevere
@tayyabamir8767
@tayyabamir8767 2 роки тому
Your videos helped me alot in learning , very much interesting.
@emirhandemir3872
@emirhandemir3872 Рік тому
Best C++ channel on UKposts ever :)
@CodeBeauty
@CodeBeauty Рік тому
🥰❤
@koko-mt7zr
@koko-mt7zr 2 роки тому
more problems mean more progress, thanks For Uploading Keep up The Good Work love you
@CodeBeauty
@CodeBeauty 2 роки тому
🙏💙
@mba2ceo
@mba2ceo Рік тому
She is BEST teacher I EVER had ... but I still feel inept. Thank U !!!
@docsduarte1999
@docsduarte1999 Рік тому
Thank you soo much, I had a lot of fun learning with your video. Very interesting.
@alexfrozen
@alexfrozen Рік тому
Thank you! Amazing)
@muhammedmame8980
@muhammedmame8980 11 місяців тому
it is great thank you so much I loved it, you are amazing
@sanjishmaharjan557
@sanjishmaharjan557 2 роки тому
You are a great teacher. lots of love❤
@thirstforknowledge7634
@thirstforknowledge7634 2 роки тому
Thank you very much for making this amazing video !!
@refikalpertuncer8512
@refikalpertuncer8512 2 роки тому
Well explained. Good content, definetely.
@sydwellnkhabela387
@sydwellnkhabela387 2 роки тому
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
@shendoo2020
@shendoo2020 2 роки тому
Thank you, This video is very helpful to understand operators override.
@careerspack
@careerspack 2 роки тому
The hottest coder online. One more reason to study coding.
@fizzaawais7585
@fizzaawais7585 2 роки тому
Thankuuu soo much❤ this video helped me alot to clear my concepts
@marouasedoud7033
@marouasedoud7033 2 роки тому
Thank you so much YOU ARE AMAZING i wish you were my university professor 💯
@SaidBADDAG
@SaidBADDAG 2 роки тому
Thank you so much, it's really helpfull
@faizanshaikh2588
@faizanshaikh2588 2 роки тому
Thanks for c programming video I need this type of video
@quocanhtruong8897
@quocanhtruong8897 2 роки тому
thank a lot Mrs!!👍👍 your teach is so detail and clear
@CodeBeauty
@CodeBeauty 2 роки тому
🤗🥰🥰
@dileepbokka5525
@dileepbokka5525 2 роки тому
Thank you , excellent teaching Madam
@harrysbidos
@harrysbidos 9 місяців тому
You make complex conceps easy to understand.
@nawabkhan9462
@nawabkhan9462 2 роки тому
Waiting , i am your regular student.
@CodeBeauty
@CodeBeauty 2 роки тому
Welcome back! Hope you'll enjoyed it! ❣️❣️
@anonymousfan9703
@anonymousfan9703 2 роки тому
@@CodeBeauty because I know Somewhere deep down in my heart I still love you ❤
Friend functions and classes in C++ (Programming for beginners)
18:18
CodeBeauty
Переглядів 103 тис.
одни дома // EVA mash @TweetvilleCartoon
01:00
EVA mash
Переглядів 5 млн
Зомби Апокалипсис  часть 1 🤯#shorts
00:29
The "this" keyword in C++
6:08
The Cherno
Переглядів 241 тис.
Operator Overloading Using Friend Functions | C++ Tutorial
15:04
Portfolio Courses
Переглядів 8 тис.
the TRUTH about C++ (is it worth your time?)
3:17
Low Level Learning
Переглядів 564 тис.
C++ OOP - What is polymorphism in programming? (simple example)
15:20
CodeBeauty
Переглядів 110 тис.
Operator Overloading Introduction | C++ Tutorial
8:01
Portfolio Courses
Переглядів 8 тис.
Broken Flex Repair #technology #mobilerepair
0:50
ideal institute aligarh
Переглядів 1,4 млн
Samsung or iPhone
0:19
rishton_vines😇
Переглядів 3,1 млн
Рекламная уловка Apple 😏
0:59
Яблык
Переглядів 723 тис.
#Shorts Good idea for testing to show.
0:17
RAIN Gadgets
Переглядів 1,1 млн