Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
usually :
std::ostream& operator <<(std::ostream& ostrm)
{
ostrm << "Hello its overloaded\n";
return ostrm;
}
std::istream& operator >>(std::istream& istrm)
{
cout<<"Enter a number : ";
istrm >> MyClass::myNumber;
return istrm;
}
note overloading the << operator should be a friend, so you can use it like this :
cout << myClassVar;
if not then you would use this syntax :
myClassVar <
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608