[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
overloaded ops << and >>
From: |
jalkadir |
Subject: |
overloaded ops << and >> |
Date: |
30 Jun 2005 09:02:36 -0700 |
User-agent: |
G2/0.2 |
I have a class that overloads the inserter and the extractor operators,
but there is a problem with the way I worte the methods; because the
compiler does not like it at all.
This is the snip of what the problem looks like:
--- money.hpp
friend std::ostream& std::operator<<( std::ostream&, const jme::Money&
); friend std::istream& std::operator>>( std::istream&,
jme::Money& );
--- money.cpp
std::ostream&
std::operator<<( std::ostream& os, const jme::Money& obj ) {
os << obj.getAmount();
return os;
}
std::istream&
std::operator>>( std::istream& is, jme::Money& obj ) {
is >> obj.amount;
return is;
}
--- error
In file included from money.cpp:2:
money.hpp:67: error: `std::ostream& std::operator<<(std::ostream&,
const jme::Money&)' should have been declared inside `std'
money.hpp:68: error: `std::istream& std::operator>>(std::istream&,
jme::Money&)' should have been declared inside `std'
What am I doing wrong?
Can anybody help?
TIA
- overloaded ops << and >>,
jalkadir <=