title: Why can't my compiler find my function?
body: <p>I am just learning how to use C/C++ and am trying to write a program in which "otherPerson" (first name, last name) inherits from "person" (first name).  I'm stuck on the compareTo function for person.  It is supposed to sort an array of pointers to person alphabetically by first name.  (not sure if I expressed that idea correctly). The end goal is to print the sorted contents of the array.</p>
  
  <p>I keep getting:</p>
  
  <blockquote>
    <p>error LNK2019: unresolved external symbol "void __cdecl compareTo(class person * * const,int)" (?compareTo@@YAXQAPAVperson@@H@Z) referenced in function _main
    1>c:\users\laur\documents\visual studio 2012\Projects\Project1\Debug\Project1.exe : fatal error LNK1120: 1 unresolved externals</p>
  </blockquote>
  
  <p>when I try to build.  I've looked around the internet for more information, but I'm pretty sure my include statements are correct.  The function is intended as a member function.</p>
  
  <p>Test.cpp:</p>
  
  <pre><code>#include "stdio.h"
     #include "otherPerson.h"
     #include&lt;iostream&gt;
     #include &lt;string&gt;
     using namespace std;
        void compareTo(person *array[7], int );
         int main(){
             int length = 7;
             person* epicJourney[6];
            //fill array
             compareTo(epicJourney, length);
  </code></pre>
  
  <p>person.h:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string&gt;
  using namespace std;
  
  class person {
      protected:
          string firstName;
      public: 
          person(string firstName);
          virtual void setFirstName(string firstName);
          virtual string getFirstName();  
          virtual void compareTo (person *array[7], int length);
          virtual string toString();
  };
  </code></pre>
  
  <p>person.cpp:</p>
  
  <pre><code>#include "person.h"
  #include &lt;string&gt;
  using namespace std;
  person::person(string firstName){
      this-&gt;firstName = firstName;
  }
  
  void person::setFirstName(string aName){
      firstName =aName;
  }
  
  string person::getFirstName(){
      return ((*this).firstName);
  }
  
  string person::toString(){
      return (this-&gt;firstName);
  }
  
  void person::compareTo(person *array[], int length){
      int i;
      int j;
  
      person *current;
  
      for (i=1; i&lt;length; i++){
          current = array[i];
          for (j=i; j&gt;=1 &amp;&amp; (current &lt; array[j-1]); j--){
              array[j] = array[j-1];
              array[j-1] = current;
          }
  
      }
  }
  </code></pre>