title: Get class pointer from a vector via function argument
body: <p>I have a class</p>
  
  <pre><code>class MyClass {
     public:
       string name;
  };
  </code></pre>
  
  <p>I have a class manager, with a vector of said classes.</p>
  
  <pre><code>class MyManager { 
   public:
     vector&lt;MyClass&gt; classes;
  };
  </code></pre>
  
  <p>I want to pull out a class from the vector by looping and matching with the name</p>
  
  <pre><code>int MyManager::FindMyClass(string name, MyClass *clazz){
      vector&lt;MyClass&gt;::iterator it;
      for(it = classes.begin(); it != classes.end(); ++it){
          if(it-&gt;name == name){
              // if i cout here, i see the cout, so i did find it..
              *clazz = *it;
              return 1;
          }
      }
      return 0;
  }
  
  int main() {
      MyClass *myClass;
      int result = myManager.FindMyClass("bob", *myClass);
  }
  </code></pre>
  
  <p>I know for a fact that the object is matched properly (see the comment). I've tried every combination of pointers, double pointers, references, and get every error from unknown conversions to invalid pointers. I am just not sure what I have to do to get a reference to the class stored in the vector.</p>