|
From: <de...@ci...> - 2003-12-23 02:00:01
|
Enum types are NOT the same as const int.
Each declared enum is a separate user defined type in the same way that
each different class is.
You could add a cast in the operator<< definition.
In article <3FE...@ne...>, Esc...@ne...
(Maya) wrote:
> Can someone please help me?
> I am using an enum type that I want to store in a std::IOStream object,
> but the compiler [complainer] tells me that the format is not
> supported. enum types are the same as 'const int' right? So, there
> should not be a problem!
>
> namespace jme{
> enum account_t {Zero, One, Two};
> class Account{
> protected:
> account_t type;
>
> ....
> public:
> friend std::istream&
> jme::operator>>(std::istream& is, jme::Account& obj){
> is >> obj.type; // <<======== Here is the problem ****
> return is;
> }
> };
> }
> This gives me an error that reads:
> ====================================================
> account.H: In function `std::istream& jme::operator>>(std::istream&,
> jme::Account&)':
> account.H:91: no match for `std::basic_istream<char,
> std::char_traits<char> >&
> >> jme::account_t&' operator <<<<<<<====== This is the problem *****
> ...: candidates are:
>
> /* Gives me a list of other candidates */
>
> ====================================================
>
|