Quick Q: Templated Function results in Circular Inclusion

Save to:
Instapaper Pocket Readability

Quick A: Separate definition and implementation.

Recently on SO:

Templated Function results in Circular Inclusion

Define registerEvent after IApp.

class IApp;

class Component
    IApp* app;
    template<typename T>
    void registerEvent(const int& evtId, Status (T::*func) (int));

class IApp : public Component {

template <typename T>
Component::registerEvent(const int& evtId, Status (T::*func) (int)) {
  auto res = std::bind(func, (T*)this, std::placeholders::_1);

If need be, also define A::registerEvent after Component::registerEvent.

Add a Comment

You must sign in or register to add a comment.

Comments (0)

There are currently no comments on this entry.