operators for classes
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
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 ]
[ 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 ]
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!
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
Popular Topics
Advertisement