c++ - Ostream << operator overloading and it's return type -
c++ - Ostream << operator overloading and it's return type -
i learnt how operator overloading of stream insertion operator. 1 uncertainty remains.
#include<iostream> class int { int i; friend std::ostream& operator<<(std::ostream&,int&); public: int():i(100){} }; std::ostream& operator<<(std::ostream& obj,int & data) { obj<<data.i; homecoming obj; } int main() { int obj; std::cout<<obj; }
what significance return obj;
has?
do return have utilize further?
are forced return because of syntax of operator<< without usefulness?
remember how can write code this:
cout << "the info is: " << somedata << endl;
this same as:
((cout << "the info is: ") << somedata) << endl;
for work, <<
operator has homecoming stream.
c++ operator-overloading
Comments
Post a Comment