Subj : Re: std streams and enum? To : alt.comp.lang.learn.c-c++,borland.public.cpp.borlandcpp From : Ulrich Eckhardt Date : Mon Dec 22 2003 12:42 am Maya wrote: > enum account_t {Zero, One, Two}; > std::istream& > jme::operator>>(std::istream& is, jme::Account& obj){ > is >> obj.type; // <<======== Here is the problem **** > return is; > } > account.H: In function `std::istream& jme::operator>>(std::istream&, > jme::Account&)': > account.H:91: no match for `std::basic_istream std::char_traits >& > >> jme::account_t&' operator <<<<<<<====== This is the problem ***** > ...: candidates are: Well, how should IOStreams know about your enumeration and how it is supposed to be written to a stream? One simple solution is to overload the operator for it, another is to just use a temporary int and a static_cast<>. One more note, you can nest enumerations inside classes/structs: class Account { enum Type { one, two, three }; }; The fully qualified type is then Account::Type (just like with namespaces). Uli -- Questions ? see C++-FAQ Lite: http://parashift.com/c++-faq-lite/ first ! .