title: c++ passing a pointer to a function that takes a reference
body: <p>I have the following functions in two classes:</p>
  
  <pre><code>Student::Student(const string &amp; FName, const string &amp; LName, const int ID){
      first = FName;
      last = LName;
      id = ID;
  </code></pre>
  
  <p>the above function in the <code>student</code> class, and the code below in the <code>students</code> class</p>
  
  <pre><code>Students::Students(){
  
  }
      void Students::add(Student &amp; aStudent){     
              collection.push_back(&amp;aStudent);
  }
  </code></pre>
  
  <p>where <code>collection</code> is a vector that is a private member of the <code>Students</code> class. In my main function, I create a student with the following:</p>
  
  <pre><code>student* bob = new student ("Bob" "Jones" 10000909); 
  </code></pre>
  
  <p>I want to now add this student to the vector of students. I have tried various code such as below:</p>
  
  <pre><code>students::add(bob)
  students::add(*bob)
  </code></pre>
  
  <p>However, these both result in errors such as: </p>
  
  <pre><code>no known conversion for argument 1 from ‘Student*’ to ‘Student&amp;’
  </code></pre>
  
  <p>I was wondering what I am doing wrong when trying to add students. </p>
  
  <p>Main:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "student.h"
  #include "students.h"
  using namespace std;
  
  
  int main(){
    Student* bob = new Student ("Bob" "Jones" 10000909);
    Students::add(bob); //error occurs  
    return 0;
  
  }
  </code></pre>
  
  <p>Student h:</p>
  
  <pre><code>#include &lt;ostream&gt;
  #include &lt;string&gt;  
  class Student {
  
      public:
      StudentStudent(const string &amp; FName, const string &amp; LName, const int ID);
  
      private:
  
      string first;
      string last;
      int id;
  
  };
  </code></pre>
  
  <p>students h:</p>
  
  <pre><code>#include &lt;ostream&gt;
  #include &lt;vector&gt;
  #include "student.h"
  #include &lt;string&gt;
  
  using namespace std;
  
  class Students {
  
      public:
      Students(); 
      void add(Student &amp; aStudent);
  
      private:
  
      vector&lt;Student*&gt; collection;
  
  };
  </code></pre>