Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit</strong><br> Okay, after rethinking everything, the problem lies with <code>ListenerBase&lt;MyClass, Button&gt;</code> and <code>ListenerBase&lt;MyClass, Label&gt;</code> each defining an <code>addHandler</code> function, which because of inheritance doesn't seem to count as overloading, even though they have different signatures (one with a <code>Button*</code> parameter, the other with a <code>Label*</code> one). One possible fix I found for this is to fully qualify the call to <code>addHandler</code>, a bit verbose and maybe not what was really desired, but it works (for convenience, I <code>typedef</code>'d the base classes):</p> <pre><code>template&lt;class Type&gt; class ButtonListenerHandler : public ListenerBase&lt;Type, Button&gt;{ public: typedef ListenerBase&lt;Type, Button&gt; ButtonListenerBase; }; template&lt;class Type&gt; class LabelListenerHandler : public ListenerBase&lt;Type, Label&gt;{ public: typedef ListenerBase&lt;Type, Label&gt; LabelListenerBase; }; class MyClass : public ButtonListenerHandler&lt;MyClass&gt;, public LabelListenerHandler&lt;MyClass&gt;{ public: void buttonHandlerFunction(); void labelHandlerFunction(); MyClass(){ ButtonListenerHandler&lt;MyClass&gt;::addHandler(m_btn, &amp;MyClass::buttonHandlerFunction); LabelListenerHandler&lt;MyClass&gt;::addHandler(m_label, &amp;MyClass::labelHandlerFunction); } private: Button* m_btn; Label* m_label; }; </code></pre> <p><strong>'nother Edit</strong><br> Thanks to the fast answer to <a href="https://stackoverflow.com/questions/5368862/why-do-multiple-inherited-functions-with-same-name-but-different-signatures-not-g">my question here</a>, I can give it another edit. The <code>using</code> method mentioned there also applies to your problem. :)</p> <pre><code>class MyClass : public ButtonListenerHandler&lt;MyClass&gt;, public LabelListenerHandler&lt;MyClass&gt;{ public: using ButtonListenerHandler&lt;MyClass&gt;::addHandler; using LabelListener&lt;MyClass&gt;::addHandler; void buttonHandlerFunction(){ } void labelHandlerFunction(){ } MyClass(){ addHandler(m_btn, &amp;MyClass::buttonHandlerFunction); addHandler(m_label, &amp;MyClass::labelHandlerFunction); } private: Button* m_btn; Label* m_label; }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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