C++ trouble setting enum field in structure constructor

I'm trying to set an enum in a structure constructor but I can't quite get the syntax correct. Are there any suggestions? This is what I have but I keep getting errors.

struct Event{
    enum eventType { Arrival, CPUburstCompletion, IOcompletion, TimerExpired }enumField;
    double time; // Defined as time units since the start of the simulation

    Event(eventType e, double theTime): enumField(e), time(theTime){}
};

Answers


Maybe...

struct Event {
  enum TYPE {
    Arrival,
    CPUBurstCompletion,
    IOCompletion,
    TimerExpired
  };
  double time;  
  TYPE type;  
  Event(Event::TYPE type, double time)
      : type(type),
        time(time) { }
};

int main() {
  Event e(Event::Arrival, 1.0);
  return 0;
}

Have you tried this?

struct Event{
    enum eventType { Arrival, CPUburstCompletion, IOcompletion, TimerExpired };

    eventType enumField;


    double time; // Defined as time units since the start of the simulation

    Event(eventType e, double theTime): enumField(e), time(theTime){}
};

Need Your Help

How to append a constant value to a relation in pig

hadoop apache-pig

I want to keep the tuple count of a relation to do some calculation, what is the most efficient solution. Currently i approach it like this :

PlayscapeManager won't initialize on android device

android unity3d playscape

Im not getting any errors or debug messages in adb logcat.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.