Note that there are some explanatory texts on larger screens.

plurals
  1. POOverridden function pointer problem at template base class C++
    text
    copied!<p>I implemented a template base class for observer pattern,</p> <pre><code>template&lt;class T&gt; class ActionListener { public: ActionListener(void); virtual ~ActionListener(void); void registerListener(T* listener); void unregisterListener(T* listener); template&lt;typename Signal&gt; void emit(Signal signal); template&lt;typename Signal, typename Parameter&gt; void emit(Signal signal, const Parameter&amp; parameter); template&lt;typename Signal, typename Parameter1, typename Parameter2&gt; void emit(Signal signal, const Parameter1&amp; parameter1, const Parameter2&amp; parameter2); private: std::vector&lt;T*&gt; mListenerList; }; class IEventListener { public: virtual void messageArrived( Message* message); virtual void messageArrived(ClientHandle* handle, Message* message); }; </code></pre> <p>i am using classes like this</p> <pre><code>emit(&amp;IEventListener::messageArrived, message); emit(&amp;IEventListener::messageArrived, mHandle, message); </code></pre> <p>the problem here is, compiler cannot deduce template parameters and i couldn't gave template parameters explicitly?</p> <p>Do someone have an idea ??</p> <p>EDIT: Problem here is overridden function calling with template parameters."Emit" function works correctly for other function types.</p> <p>Usage of this pattern is </p> <pre><code>class SampleClass : public ActionListener&lt;IEventListener&gt; { //some stuff here //this class is observing events of IEventListener } </code></pre> <p>by the way this is C++.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload