[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

enum value and serialization

Posted on 2004-10-12
4
Medium Priority
?
830 Views
Last Modified: 2013-11-20
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 ;
}


 
0
Comment
Question by:Surfer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 12

Accepted Solution

by:
OnegaZhang earned 2000 total points
ID: 12293922
Do like this. (Althrough << does not complain, you still have to cast its type for safety)
      if (ar.IsStoring())
      {
            ar << (LONG)m_eMyEnum ;
      }
      else
      {
            ar>> (LONG&)m_eMyEnum ;
      }
0
 
LVL 6

Expert Comment

by:Amritpal Singh
ID: 12295109
have a look at the "code" at the following  link

http://www.codeguru.com/Cpp/data/data-misc/xml/article.php/c4567/
0
 

Author Comment

by:Surfer
ID: 12560465
Thanks for reminding me to give the well deserved points!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question