Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One way to do this would be:</p> <pre><code>class Base { public: Base(); virtual ~Base(); virtual void doSomething(); }; class DerivedOne : public Base { public: DerivedOne(); void doSomethingElse(int a,struct b); }; class DerivedTwo : public Base { public: DerivedTwo(); virtual void doSomething(); }; </code></pre> <p>You could then use <code>dynamic_cast</code> to determine the type at runtime since you seem to have a type-conditional expression someplace in <code>SomeClass</code>. The methods are not equal and fundamentally distinct. Also, <code>DerivedOne::doSomething</code> would hide <code>Base::doSomething</code>.</p> <p><strong>Update</strong></p> <p>As the others had already stated, it's often a bad smell if your program relies on type-conditional expressions. Since your example does not have enough context to offer appropriate solutions, it's hard for us to help you in this regard. If you are interested in removing the type-conditional, one of many potential solutions to this problem would be:</p> <pre><code>class Base { public: Base(); virtual ~Base(); virtual void doSomething(); }; class DerivedOne : public Base { public: DerivedOne(); // ... virtual void doSomething(); // &lt;&lt; no parameters required. // they have moved to member data: private: int a; b another; }; class DerivedTwo : public Base { public: DerivedTwo(); virtual void doSomething(); }; </code></pre> <p>then you could remove the type-conditional expression from your program. If you'd like help in this regard, feel free to ask here or open a new question if you feel it is more appropriate.</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. 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