Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4038134
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:26:07+00:00 2026-05-20T12:26:07+00:00

Consider this syntactically correct(?) pseudocode: class Event { public: virtual int getID() const =

  • 0

Consider this syntactically correct(?) pseudocode:

class Event {
public:
    virtual int getID() const = 0;
    virtual int getSize() = 0;
    virtual void* getData() = 0;
    virtual void setData() = 0;
    //(I cannot define data at this level 'cos I don't know what it is yet)
}

class SpecialEvent : class Event {
public:
    virtual int getPGNID() const = 0;
    int getSourceAddress() {return source_address;}
    int setSourceAddress(int source_address) {this->source_address = source_address;}
protected:
    int source_address;
}

template <typename T, typename E>
class EventWrapper : public E {
    T data;
public:
    static int EVENT_ID;
    //implements everything in Event...EVENT_ID is assigned at runtime by some registry
}

class AnEvent : public EventWrapper<int, Event> {
     //public methods specific to AnEvent...
}

class AnotherEvent : public EventWrapper<long, SpecialEvent> {
    int getPGNID() const {static int ID = 10; return ID;}
}

class TheProcessingClass {
    AnEvent event1;
    AnotherEvent event2;

    void process(Event& e);
    void process(SpecialEvent& e);

    void doSomething() {
        process(event1);  //should invoke process(Event&)
        process(event2);  //should invoke process(SpecialEvent&)
    }
}

Essentially, I have a wrapper class that wraps data of type T and inherits from some type of E (in this case Event or SpecialEvent)…

I initially was going to create two wrapper classes EventWrapper and SpecialEventWrapper until I figured out that both classes would have the exact same code in it (as long as it was extending from some type of Event)

First off, this sounds like a policy-based design. However, the Events don’t have any special behavior…they just hold some data… Am I abusing this pattern?

Second off, is there a better way to do this? I’m oversimplifying things greatly here, but any insights will be appreciated…

EDIT
I updated my example…in short, the processing classes are listening for Events and should take action based on the Event. I hope this helps…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:26:08+00:00Added an answer on May 20, 2026 at 12:26 pm

    I suggest adding process() as a member function of class event.

    class Event {
        int getID() const;
        void process();
        //class stuff
    }
    
    class SpecialEvent : class Event {
        int getSpecialID() const;
        void process(); //special version of process()
        //class stuff
    }
    
    
    class TheProcessingClass {
        Event event1;
        SpecialEvent event2;
    
        void doSomething() {
            event1.process();
            event2.process();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.