Note that there are some explanatory texts on larger screens.

plurals
  1. POOverriding multiple inherited templated functions with specialized versions
    primarykey
    data
    text
    <p>Okay, sample code first; this is my attempt at communicating what it is that I'm trying to do, although it doesn't compile:</p> <pre><code>#include &lt;iostream&gt; template &lt;class T&gt; class Base { public: virtual void my_callback() = 0; }; class Derived1 : public Base&lt;int&gt; , public Base&lt;float&gt; { public: void my_callback&lt;int&gt;() { cout &lt;&lt; "Int callback for Derived1.\n"; } void my_callback&lt;float&gt;() { cout &lt;&lt; "Float callback for Derived\n"; } }; class Derived2 : public Base&lt;int&gt; , public Base&lt;float&gt; { public: void my_callback&lt;int&gt;() { cout &lt;&lt; "Int callback for Derived2.\n"; } void my_callback&lt;float&gt;() { cout &lt;&lt; "Float callback for Derived2\n"; } }; int main() { { Derived1 d; Base&lt;int&gt; * i_p = d; Base&lt;float&gt; * i_f = d; i_p-&gt;my_callback(); i_f-&gt;my_callback(); } { Derived2 d; Base&lt;int&gt; * i_p = d; Base&lt;float&gt; * i_f = d; i_p-&gt;my_callback(); i_f-&gt;my_callback(); } //Desired output: // Int callback for Derived1. // Float callback for Derived1 // Int callback for Derived2. // Float callback for Derived2 system("Pause"); } </code></pre> <p>So, what I'm trying to do is to make a sort of wrapper class to inherit from that will automatically connect the derived class to various callback lists; it needs to connect a specific instance of the derived class to the list, and I want the "user" to have / get to make the callback functions as part of making the derived class, as you can see. </p> <p>It seems like this should be able to work, although I may need to use a different syntax. If it can't work, do you have any suggestions?</p>
    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.
 

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