No video

Stream Insertion | Stream Extraction Operator Overloading In C++

  Рет қаралды 63,430

CppNuts

6 жыл бұрын

JOIN ME
-----
KZbin 🎬 kzbin.info/door/s6sf4iRhhE875T1QjG3wPQjoin
Patreon 🚀 www.patreon.com/cppnuts
COMPLETE PLAYLIST
------------
C++ Tutorial For Beginners: kzbin.info/www/bejne/aXrcn6mtn9eJY7c
STL (Standard Template Library): kzbin.info/www/bejne/gqqqnYejlrx4htU
ThreadIng In C++: kzbin.info/www/bejne/ioG5eZKZpKx0h9U
Data Structures: kzbin.info/www/bejne/baWvh4CLgLGoaNU
Algorithms: kzbin.info/www/bejne/anfbcn5nqc9_qtE
Design Patterns: kzbin.info/www/bejne/jqqxiHiNiriUa6c
Smart Pointers: kzbin.info/www/bejne/rYbdn2N-oc-diKc
C++14: kzbin.info/www/bejne/Z3akfZKIh6h-nrs
C++17: kzbin.info/www/bejne/l3mapYyNn9OXnc0
C++ All Type Casts: kzbin.info/www/bejne/fp2xh5qjq71ke6s
INTERVIEW PLAYLIST
------------
C++ Interview Q&A: kzbin.info/www/bejne/h4TYc6p9oquEp6M
C++ Interview Q&A For Experienced: kzbin.info/www/bejne/pmPdaIaAarKKjJo
Linked List Interview Questions: kzbin.info/www/bejne/g2bXgmecf7KmqJI
BST Interview Questions: kzbin.info/www/bejne/iInIemqhbtebnac
Array Interview Questions: kzbin.info/www/bejne/kGO3pp-HnJqnaZI
String Interview Questions: kzbin.info/www/bejne/hp_LfWCZaJt9sK8
Bit Manipulation Questions: kzbin.info/www/bejne/b3S6h5uraJ2UY7M
Binary Tree Interview Question: kzbin.info/www/bejne/l6XXYq2mp96pedk
Sorting Algorithms: kzbin.info/www/bejne/jKeQmKZqaJycaMk
C++ MCQ: kzbin.info/www/bejne/iHvUhGWArNGAbKc
C MCQ: kzbin.info/www/bejne/r4PddnqQYraiq7c
C Interview Questions: kzbin.info/www/bejne/iIK9and7adOIiJY
QUICK SHORT VIDEOS
-------------
C++ Short : kzbin.info/aero/PLk6CEY9XxSIChg28m9UnVkPpfJobvlheb
C Short : kzbin.info/aero/PLk6CEY9XxSIAPNa21YdP5jcwaRgEfXF4-
In this video we will learn "Stream Insertion And Stream Extraction Operator Overloading" in c++ programming language.
There are few points to remember is as follows:
1. When we need overload these operators?
2. It can't be class member function (reason we will discuss), you have to make it friend function of your class.
You will get to know why we need to overload these operators in c++.
#inheritance #oops #cpp #programming #tutorial #computerscience #softwareengineering

Пікірлер: 118
@Latif.Kakule
@Latif.Kakule 4 жыл бұрын
God bless you.. I just learned so much for free than from a book I bought for 50 dollars..
@CppNuts
@CppNuts 4 жыл бұрын
Thanks man!!
@khalidaaliyeva2250
@khalidaaliyeva2250 4 жыл бұрын
"" is stream extraction operator. The left-hand operand of this operator must be an istream object. Again, the direction of the arrows indicates that we read from the stream. We extract from the stream.
@maheiramkhan
@maheiramkhan 4 жыл бұрын
Thanks.
@samircasen8117
@samircasen8117 3 жыл бұрын
you all probably dont care at all but does any of you know a way to log back into an Instagram account..? I somehow lost my account password. I appreciate any assistance you can give me.
@emoryuriel6861
@emoryuriel6861 3 жыл бұрын
@Samir Casen Instablaster ;)
@samircasen8117
@samircasen8117 3 жыл бұрын
@Emory Uriel Thanks for your reply. I found the site through google and I'm in the hacking process atm. I see it takes quite some time so I will reply here later with my results.
@samircasen8117
@samircasen8117 3 жыл бұрын
@Emory Uriel It worked and I actually got access to my account again. I'm so happy:D Thanks so much you really help me out :D
@kolibri5861
@kolibri5861 5 жыл бұрын
In C++, stream insertion operator “” is used for input. you are mistaken
@CppNuts
@CppNuts 5 жыл бұрын
Oh its my bad, only thumbnail is the issue or i said something wrong in video also?
@DEEPAKKUMAR-sw6sb
@DEEPAKKUMAR-sw6sb 4 жыл бұрын
good one. I had confusion on this topic and you explained it very nicely. Thanks!
@CppNuts
@CppNuts 4 жыл бұрын
Glad it was helpful!
@piyushverma5417
@piyushverma5417 7 күн бұрын
awesome bro, you just given me enough knowlegde, i am working on a project in c++, i am trying to make dynamic list with class as an object, for that i need to learn many things , it is very helpful.
@Byynx
@Byynx 11 ай бұрын
Congratulations for this video, you're a real master and teacher.
@dansdailydare
@dansdailydare Жыл бұрын
thank u so much, i've been stuck on this for long time, didn't understand wtf is this. Thanks
@himanshurajpal7842
@himanshurajpal7842 3 жыл бұрын
Brother !! Your this video clear all my doubts which was frustating me so much ,,, I want to applaud you by a thing which is called money 🤑 in this world. But right now ,I am struggling in my career with lack of money.... , Whenever i will be successful , I will do something. And for right now ,I will share your channel to tons of my friends.
@CppNuts
@CppNuts 3 жыл бұрын
Thanks buddy for such a good comment.
@sameerneupane158
@sameerneupane158 10 ай бұрын
wooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooow sir amazing, thanks for making us so clear about this topic,,,,,,,,,,Lots of love from Nepal sir❤
@nastaranhendijani681
@nastaranhendijani681 7 ай бұрын
it was very useful video, I was confused on this subject and I understand now, thank you very much!
@Byynx
@Byynx 11 ай бұрын
Guys you don't need to do "friend std::ostream& operator
@ChandraShekhar-by3cd
@ChandraShekhar-by3cd 5 жыл бұрын
Best Tutorials on operator overloading...Just had a request if You can post more videos on C++ graphics Programming
@CppNuts
@CppNuts 5 жыл бұрын
No Graphics experience.
@smeetkathiria6633
@smeetkathiria6633 5 жыл бұрын
There are good courses on Udemy check it out.
@KZainUlAbideen
@KZainUlAbideen 6 жыл бұрын
sir, a very helpful video, thank u and inshaAllah you will get 1 million subscribers soon.
@CppNuts
@CppNuts 6 жыл бұрын
InshaAllah.. Thank you so much for your beautiful comment !!
@moonwalkingdancer8369
@moonwalkingdancer8369 2 жыл бұрын
hey hold on why do we use referances in ostream&operatror
@heybuddy_JAI_SHREE_RAM
@heybuddy_JAI_SHREE_RAM Жыл бұрын
this explanation just blow my mind 🤯🤯u have got a new subsciber
@CppNuts
@CppNuts Жыл бұрын
Thanks man..
@AkhileshSingh-y4v
@AkhileshSingh-y4v 8 ай бұрын
I have a question: At 6:35 timestamp, you said that if the data members which we are using for '' operation are if public then we don't need to use friend keyword. my problem: I tried to overload the function in a template of struct but i wasn't able to do it without making the overloaded function as a friend function. But all the members of struct are public by default then why I have to make that overloaded function as friend function. (All the declarations are inside the struct template). Please help me in this.
@supernovaw39
@supernovaw39 8 ай бұрын
Which Sublime Text theme is it? With those trapezoidal tabs.. I searched all over the internet couldn't find it :(
@adityathakur1961
@adityathakur1961 3 жыл бұрын
Really very well explained.. thank you so much
@CppNuts
@CppNuts 3 жыл бұрын
You are most welcome
@te_b_52_siddeshpatankar14
@te_b_52_siddeshpatankar14 3 жыл бұрын
Superb explanation.....Hats off Sir👍🏻👍🏻💯💯💯💯💯💯
@CppNuts
@CppNuts 3 жыл бұрын
Thanks
@omkarsalapurkar2981
@omkarsalapurkar2981 2 жыл бұрын
Thanks man you have really explained it very well!
@pushkarkumarsharma3256
@pushkarkumarsharma3256 4 жыл бұрын
Sir, I don't understand if we return input, output but where we receive it . In the example P1=P2+ P3 here we return and store it into P1 but in this example input and output return but where we receive it this thing I don't understand.
@buidu691
@buidu691 4 жыл бұрын
i don't really understand line 22,return input statement just is cin copy ,Do i think right ? Pls explain for me.Tks a lot
@seankang8318
@seankang8318 5 жыл бұрын
Thanks for this video. Really helped me understand
@NoOne-lj3zb
@NoOne-lj3zb 2 жыл бұрын
You explain well
@CppNuts
@CppNuts 2 жыл бұрын
Thanks
@NoOne-lj3zb
@NoOne-lj3zb 2 жыл бұрын
After watching this video i subscribe your channel
@CppNuts
@CppNuts 2 жыл бұрын
Thanks.. 👍
@couldrain2971
@couldrain2971 4 жыл бұрын
You're so good at explaining TY!!!
@CppNuts
@CppNuts 3 жыл бұрын
You are welcome..
@Turkish_Microwave
@Turkish_Microwave 8 ай бұрын
thanks man this really helped me out !
@hassankamran3480
@hassankamran3480 3 жыл бұрын
How are you calling private data members just by objects? Shouldn't we be using getter function instead?
@syedatifshah8020
@syedatifshah8020 2 жыл бұрын
Full of information...i am very pleased sir .may allah bless you
@CppNuts
@CppNuts 2 жыл бұрын
Thanks
@maheiramkhan
@maheiramkhan 4 жыл бұрын
This was very helpful. Thankyou, sir.
@CppNuts
@CppNuts 4 жыл бұрын
Welcome!!
@surajnaik4645
@surajnaik4645 4 жыл бұрын
Test(int x=0) :x{x} {},can u tell me what does this line do and what does x{x} do?
@CppNuts
@CppNuts 4 жыл бұрын
It initialise x into x.
@Chopperaemon
@Chopperaemon 5 жыл бұрын
line number 15: Test(int x=0):x{x} {} what does that x{x} does in this statement and why is there an empty bracket??
@Sindujaify
@Sindujaify 3 жыл бұрын
This is called initializer list in c++. It is similar to x = x where first x is member variable and 2nd x is passed parameter and {} is just a place holder
@rudrapratap3303
@rudrapratap3303 2 жыл бұрын
wonderful explanation!
@CppNuts
@CppNuts 2 жыл бұрын
Thanks..
@seizondhakal1047
@seizondhakal1047 7 ай бұрын
What a valuable video!! Thank you..
@ArjunArjun-vw5fq
@ArjunArjun-vw5fq 3 жыл бұрын
friend why we assign constructor with default arguments like cons_name(int x=0):x{ }{} why we are assigning x=0??
@CSSuccessGamer
@CSSuccessGamer 5 жыл бұрын
Thanks for the video! Do you have tutorial for creating binary tree class and overloading it to print out the root and left or right nodes? And for adding in new stuff to the tree?
@CppNuts
@CppNuts 5 жыл бұрын
After completing threading and STL topic i will start DS and AL.
@kkgt6591
@kkgt6591 6 жыл бұрын
Nicely explained.
@CppNuts
@CppNuts 6 жыл бұрын
Thank you so much!!
@cid007007
@cid007007 4 жыл бұрын
int main() { Base b(10); Test t(30); cout
@CppNuts
@CppNuts 4 жыл бұрын
Here is the link i wrote it for you: coliru.stacked-crooked.com/a/68ef59b37d05fd9d let me know if you still have some doubts.
@cid007007
@cid007007 4 жыл бұрын
@@CppNuts Thanks alot working : #include using namespace std; class Base { int x; public: Base(int x=0):x{x} {} friend class Test; }; class Test { int x; public: Test(int x=0):x{x}{} int operator + (Base& b) { return x+b.x; } }; int main() { Base b(10); Test t(20); cout
@CppNuts
@CppNuts 4 жыл бұрын
Good..
@akanshmishra7302
@akanshmishra7302 3 жыл бұрын
can you explain once again why we are returning by reference? Where are we returning actually? Sorry, I didn't understand that part.
@Ch_abdullah00
@Ch_abdullah00 3 ай бұрын
Well explained ❤️
@nithyanarayan8080
@nithyanarayan8080 3 жыл бұрын
Very nice video. So If I want to do it for more than one class, how will I pass my object as second parameter to overloaded functions? Can you please help me here?
@mikelai7483
@mikelai7483 3 жыл бұрын
why we need to put ostream & operator
@JohnWickXD
@JohnWickXD 3 жыл бұрын
Nope bro...Without returning reference, it will returned as a value...but we want to use it again as a cin object....
@ThatManAcid
@ThatManAcid 4 жыл бұрын
thanks this actually helped out a lot good explination
@CppNuts
@CppNuts 4 жыл бұрын
Thanks man!!
@avikmallick2493
@avikmallick2493 4 жыл бұрын
Sir in 11:21 I didn't understand how the cin>>t is becoming cin and then it is reading t1.can u plz explain?
@Sindujaify
@Sindujaify 3 жыл бұрын
because the overloaded function return cin
@stormbreaker9913
@stormbreaker9913 3 жыл бұрын
Which IDE you are using??
@CppNuts
@CppNuts Жыл бұрын
Sublime Text Editor 3
@sakshams03
@sakshams03 3 жыл бұрын
Thanks for the wonderful video, can you please explain how to write overloading function inside the class, there it gives error because reference to class is implicitly present as this keyword.
@fardinanamaungon8890
@fardinanamaungon8890 4 жыл бұрын
What will I do if my class has more than one variables?
@abhipsachatterjee5470
@abhipsachatterjee5470 3 жыл бұрын
Test(int x=0):x{x} {} in this expression what x{x} means? someone please reply
@haldharpatel3915
@haldharpatel3915 3 жыл бұрын
Well explained, thanks 😊
@CppNuts
@CppNuts 3 жыл бұрын
Glad it was helpful!
@madhurikasharma747
@madhurikasharma747 4 жыл бұрын
very helpful video
@mouaadelhansali6185
@mouaadelhansali6185 9 ай бұрын
Thank you !
@mirham3802
@mirham3802 3 жыл бұрын
Hi, You are wrong my friend about the names. Here what the documentation says: Insert formatted output This operator (
@sharoonshahzad178
@sharoonshahzad178 Жыл бұрын
i got error when i removed & from istream& >> operator and also from stream also
@preetikhanna7034
@preetikhanna7034 4 жыл бұрын
Thank you. Can we inherit istream or ostream class
@behindthescene4406
@behindthescene4406 4 жыл бұрын
Yes best example is iostream
@Rob-gn4sm
@Rob-gn4sm 4 жыл бұрын
This is so great . Thank you sir ❤️
@CppNuts
@CppNuts 4 жыл бұрын
You are very welcome
@danigol6663
@danigol6663 5 жыл бұрын
Great job
@CppNuts
@CppNuts 5 жыл бұрын
Thanks man!!
@rupeshpatil6807
@rupeshpatil6807 3 жыл бұрын
thank you so much.
@CppNuts
@CppNuts 3 жыл бұрын
Always welcome
@aishaahmad7212
@aishaahmad7212 3 жыл бұрын
Thnx a lot 💖 very useful
@CppNuts
@CppNuts 3 жыл бұрын
Glad it was helpful!
@eotcoldhymns2930
@eotcoldhymns2930 Жыл бұрын
why not const Test& obj?
@CppNuts
@CppNuts Жыл бұрын
Yes, in cout case we should use const, thanks..
@ahmedian505
@ahmedian505 10 ай бұрын
ty
@kumarAjitesh
@kumarAjitesh Жыл бұрын
Those who still have a doubt that why didn't we make (>>,
@CppNuts
@CppNuts Жыл бұрын
Thanks it will help many !!
@thpriya.22
@thpriya.22 Жыл бұрын
Thank you so much 💙 Very nice explanation 👏
@LuffyD-lv1lr
@LuffyD-lv1lr Жыл бұрын
greate one
@CppNuts
@CppNuts Жыл бұрын
Thanks
@snlagr
@snlagr 3 жыл бұрын
1:07 i legit thought its ice cream till now
@murarichaudhary5602
@murarichaudhary5602 4 ай бұрын
awesome bro... :)
@h.d_surat
@h.d_surat 10 ай бұрын
Express the use of manipulator in C++
@ChandraSekhar-tr7sf
@ChandraSekhar-tr7sf 3 жыл бұрын
thanks
@CppNuts
@CppNuts 3 жыл бұрын
You're welcome!
@Omaima-qo9qp
@Omaima-qo9qp 3 жыл бұрын
thank youuuuuuuu.
@CppNuts
@CppNuts 3 жыл бұрын
Welcome
@softsun2134
@softsun2134 Жыл бұрын
based
@ALIAYH-r7p
@ALIAYH-r7p 5 ай бұрын
👌👌👌👌👌👌👌👌👌👌👌👌👌👌
@CppNuts
@CppNuts Ай бұрын
Thanks
@ganeshlokhande6061
@ganeshlokhande6061 Жыл бұрын
Thanks a lot 🥲
@deepdesale4601
@deepdesale4601 5 жыл бұрын
Nicely explained...
@CppNuts
@CppNuts 5 жыл бұрын
Thanks man!!
Зу-зу Күлпаш 2. Интернет мошенник
40:13
ASTANATV Movie
Рет қаралды 601 М.
Cool Parenting Gadget Against Mosquitos! 🦟👶
00:21
TheSoul Music Family
Рет қаралды 12 МЛН
Flipping Robot vs Heavier And Heavier Objects
00:34
Mark Rober
Рет қаралды 41 МЛН