how can we call istream class object in our class “complex” ?
Operator overloading >>?
where is operator overloading done in class comlex ? or outside of it.
but in the webinar overloading “<<” cin sir did it outside the function.
ex. cin<<vector ?
@mehulbhandari358,
That’s because it is a unary operator, you can overload unary operator outside class also, but if for e.g you have to overload + operator, then you need to have a class.
why was << this overloaded outiside the class
@mehulbhandari358,
Because it is already a member of istream class, and we can not redefine it, thus we declare it outside the class as a friend function. Read more here
can we overload an operator outside a class
and call it for the class object.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.