operators for classes

Started by
3 comments, last by whiteguy 21 years ago
i''m trying to make an operator<< for class Date, and i don''t need to pass any parameters, but i can''t get it to compile. Please help me out
Advertisement
There are smart people in here, but not a single mind reader. Post some of the code causing the problems and exactly what errors you get.
There is no unary operator <<

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
sure there is fruny

class Date
{
public:
void operator<<(int);
};

that''s a unary operator...or wait that would still be binary becauase the left hand side is Date! damn you fruny!

  ostream& operator<< ( ostream& os, const Date& date ) {  os << date.getDay() << "/"     << date.getMonth() << "-"     << date.getYear();  return os;}  

Or something similar.

-Neophyte

This topic is closed to new replies.

Advertisement