Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>what exactly are you trying to do? it looks like you are trying to write a function that does something given two objects, and you want it to do a different thing based on the type of the combination of objects?</p> <p>remember that even normal polymorphism does "checks" internally.</p> <p>this is an interesting problem tho,</p> <p>polymorphism gives you the ability to easily overload the functionality of a function based on the type of ONE object, not two.</p> <p>what is it EXACTLY that you are trying to do? my best suggestion would be to make it so that each object could perform its own specific stuff separately and then return a common object for common processing:</p> <pre><code>class Base { virtual SomeComonInterfaceObject DoMySpecialSomething() = 0; } void _doSomething(SomeComonInterfaceObject a, SomeComonInterfaceObject b); void doSomething(Base&amp; o1, Base&amp; o2) { _doSomething(o1-&gt;DoMySpecialSomething(), o2-&gt;DoMySpecialSomething()); } </code></pre> <p>if that doesn't suit, you probably just have to check the type and do specifics based on that.</p> <p>note that even normal polymorphism does "checks" if you are worried about performance, any other language would have to too.</p> <p>the only way you might be able to get around that is by using templates, and it would probably get real ugly.</p> <p>would be interesting to know what you are trying to do. also, these doSomething functions, is it always the case that their two parameters are the same type? or do they mix and match?</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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