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(CArchiv e& ar)
{
CObject::Serialize(ar);
if (ar.IsStoring()) {
ar << m_eMyEnum ;
}
else {
ar>> m_eMyEnum ;
}
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(CArchiv
{
CObject::Serialize(ar);
if (ar.IsStoring()) {
ar << m_eMyEnum ;
}
else {
ar>> m_eMyEnum ;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for reminding me to give the well deserved points!
http://www.codeguru.com/Cpp/data/data-misc/xml/article.php/c4567/