Link to home
Start Free TrialLog in
Avatar of Surfer
Surfer

asked on

enum value and serialization

I get the following compiler error:  Why, how can I fix this problem, and what is the best way to handle enum's in serialization?  

data.cpp(66) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'enum CMyData::MyrEnum' (or there is no acceptable conversion)
Error executing cl.exe.

Given the code snippet:

class CMyData : public CCmdTarget
{
DECLARE_DYNCREATE(CMyData )

CMyData ();           // protected constructor used by dynamic creation

public:
static enum GenderEnum { enumOne = 0,   enumTwo } ;

private:
MyEnum m_eMyEnum ;

// Operations
public:
 virtual void Serialize(CArchive& ar);
}

void CMyData::Serialize(CArchive& ar)
{
 CObject::Serialize(ar);

if (ar.IsStoring()) {
ar << m_eMyEnum ;
}
else {
ar>> m_eMyEnum ;
}


 
ASKER CERTIFIED SOLUTION
Avatar of OnegaZhang
OnegaZhang

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Surfer
Surfer

ASKER

Thanks for reminding me to give the well deserved points!