title: Why won't derived class access a non-virtual base class function?
body: <p>I am having trouble making a derived class access a function that is defined in the base class.  The base class header file, called Particle.h, is:  </p>
  
  <pre><code>class Particle {
      protected:
          vector&lt;double&gt; x_,y_,z_;
  
          // lots of other protected members that are not relevant to the question
  
      public:
  
          // constructors and other functions not relevant to question are omitted
          virtual double getX(const unsigned int index, const double theta, const double phi);
          virtual vector&lt;double&gt; getX(const double theta, double Real phi);
          vector&lt;double&gt; getX(const unsigned int surfindex);
  }
  </code></pre>
  
  <p>The definition of this function is in a file called Particle.cc:</p>
  
  <pre><code>#include "Particle.h"
  
  vector&lt;double&gt; Particle::getX(const unsigned int surfindex)
  {
      vector&lt;double&gt; xp;
      xp.clear();
      xp.resize(3,0.0);
      xp[0] = x_.at(surfindex);
      xp[1] = y_.at(surfindex);
      xp[2] = z_.at(surfindex);
  
      return xp;
  }
  </code></pre>
  
  <p>The derived class header file, called Star.h, is:</p>
  
  <pre><code>#include "Particle.h"
  
  using namespace std;
  
  class Star : public Particle {
  
      public:
  
         // constructors and other functions not relevant to question are omitted here
  
         virtual void computeRoundness(const unsigned int method);
         double getX(const unsigned int index, const double theta, const double phi);
         vector&lt;double&gt; getX(const double theta, double Real phi);
  }
  </code></pre>
  
  <p>The definition of the computeRoundness function is in a file called Star.cc:</p>
  
  <pre><code>#include "Star.h"
  
  // Lots of other function definitions not relevant to question are omitted here
  
  void Star::computeRoundness(const unsigned int method)
  {
      vector&lt;double&gt; X;
      unsigned int count = 0;
      while (count &lt; ntheta) {
         X = getX(count);      // Should call base class function, right?
  
         // do some more things with X that are not relevant to this question
      }
  }
  </code></pre>
  
  <p>But I receive this compile-time error:</p>
  
  <pre><code>Star.cc: In member function ‘virtual void Star::computeRoundness(unsigned int)’:
  Star.cc:1340: error: no matching function for call to ‘Star::getX(unsigned int&amp;)’
  Star.h:687: note: candidates are: virtual double Star::getX(unsigned int, double, double)
  Star.h:696: note:                 virtual std::vector&lt;double, std::allocator&lt;double&gt; &gt; Star::getX(double, double)
  </code></pre>
  
  <p>I have successfully called base class functions from derived classes in other C++ projects in the past, so I must be overlooking something simple here, but I just can't find it.  I thought that base class functions should be inherited by derived classes unless they are declared virtual and then overridden in the derived class (but that is not the case here), even if the derived class overloads the function name as I have done here a couple of times.  Is that not true?  And if not, is there anything elegant I can do to fix the problem rather than just redefining the same functions in my derived class?</p>
  
  <p>Thanks very much for any help.</p>