title: Passing a subclass in a method that expects parent abstract class C++?
body: <p>I'm working on an assignment with the following (simplified) structure.</p>
  <pre><code>class A
  {
  public:
    virtual void method;
  }
  
  class B : public A
  {
  some variables;
  public:
    void method;
  }
  
  class C
  {
  public:
    void method1(A *a);
  }
  </code></pre>
  <p>I have a C instance and B instance and try to call c.method1(b), where b is my instance of class B.  However, it expects an A*, and gives me an error saying it can't convert B to A*.  I thought I would be able to pass instances of B in as they are subclasses of A.  How would I go about fixing this so I am able to pass B into the method, knowing that I can't change the method argument as it is part of the assignment?</p>