title: Polymorphism Implementation
body: <p>Let's say I have class A, class B which inherits A, and class C which also inherits A. Class C has method F, while class B does not. </p>
  
  <pre><code>class A {
      //Some stuffs
  };
  
  class B : public A {
      //Some stuffs.
  };
  
  class C : public A {
      void F ();
  };
  </code></pre>
  
  <p>My problem is, when I have an object that I don't exactly know what class it belongs to (it can be either B or C), I want to check that object using a pointer of class A, and if that object belongs to class C, then I would like to call method F. How do I implement those classes?  </p>
  
  <p>I would like something like this.</p>
  
  <pre><code>A *_a = Something;
  if (_a is pointing to object of class C){
      _a-&gt;F;
  }
  </code></pre>
  
  <p>Right now, I am thinking of having that method F as a virtual method in class A, but I don't think that is a really good way of doing it, because only class C actually has it and if that is how I do it, for every method that I want in class C, I would have to add it to class A too. Is there any workaround?</p>