title: Why i cant push_back an object with templates?
body: <p>i have a problem with templates and STL Vector. I want to push_back an object but i have the error:</p>
  
  <blockquote>
    <p>no matching function for call to ‘std::vector&lt;Perso>::push_back(Perso (&amp;)())’<br>
      37 |             vec.push_back(auxiliar);</p>
  </blockquote>
  
  <p>This is the code:</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  class Perso{
  private:
      int edad;
      long dni;
  public:
      Perso(){this-&gt;edad = 0; this-&gt;dni = 0;}
      ~Perso(){}
      void setEdad(int edad){
          this-&gt;edad=edad;
      }
      void setDNI(int dni){
          this-&gt;dni=dni;
      }
      int getEdad(){
          return this-&gt;edad;
      }
      int getDNI(){
          return this-&gt;dni;
      }
  };
  
  template &lt;typename T&gt;
  void cargarPersonas(vector&lt;T&gt;&amp;vec){
      ifstream nomArch;
      T auxiliar();
      nomArch.open("ArchivoBin.dat", ios::in | ios::binary);
      if(nomArch.is_open()){
          int i = 0;
          do{
              nomArch.seekg(i*sizeof(T),ios::beg);
              nomArch.read((char*)&amp;auxiliar,sizeof(T));
              vec.push_back(auxiliar);
              ++i;
          }while (!(nomArch.eof()));
          nomArch.close();
      }
  }
  template &lt;typename G&gt;
  void guardarPersonas(vector&lt;G&gt;vec){
      ofstream nomArch;
      nomArch.open("ArchivoBin.dat", ios::app | ios::binary);
      if(nomArch.is_open()){
          for(int i =0; i&lt;vec.size();++i)
          {
              nomArch.write((char*)&amp;vec.at(i),sizeof(G));
          }
          nomArch.close();
      }
  }
  int main() {
      vector&lt;Perso&gt;personas;
      cargarPersonas&lt;Perso&gt;(personas);
  }
  </code></pre>