title: C++ Class Inheritance separate methods in derived class
body: <p>I got the three classes <code>MachineLearning</code>, <code>MachineLearningSVM</code> and <code>MachineLearningAdaboost</code>. </p>
  
  <p><code>MachineLearning</code> is the base class and <code>MachineLearningSVM</code> and <code>MachineLearningAdaboost</code> derive from it.</p>
  
  <pre><code>class MachineLearning;      //Base class
  class MachineLearningSVM : public MachineLearning;   
  class MachineLearningAdaboost : public MachineLearning;
  
  class `MachineLearning` {
     public:
        virtual void Train();
  }
  
  class MachineLearningSVM : public MachineLearning {
     public:
         void Train(std::vector&lt;Feature&gt; features);
  }
  
  class MachineLearningAdaboost : public MachineLearning {
     public:
         void Train(std::vector&lt;Feature&gt; features, std::vector&lt;Label&gt; labels);
  }
  </code></pre>
  
  <p>My problem is that I would like to tell all deriving classes that they should keep a function Train(), but each deriving class should be able to have different parameters in their method definition. As seen above the Adaboost needs (exemplarily) additional labels for training.</p>
  
  <p>Consider the following:</p>
  
  <pre><code> int main(){
       MachineLearning* ml;
       switch(type){
           case SVM:
               ml = new MachineLearningSVM();
               break;
           case Adaboost:
               ml = new MachineLearningAdaboost();
               break;
       }
       ml-&gt;Train(std::vector&lt;Feature&gt;);
   }
  </code></pre>
  
  <p>C++ doesn't know at compile time which Train function to call, since its not clear if it will be of type SVM or Adaboost.</p>
  
  <p>How could I implement this scenario? I want to avoid using templates.</p>