title: Union of two class vectors in C++
body: <p>My problem is the following:</p>
  
  <p>I have two vectors of an specific class called "estado" (state):</p>
  
  <pre><code>class estado {
  vector &lt;int&gt; prev_estados;
  int g;          //coste camino
  int h;          //heuristica
  int f;          //total
  bus autobus;
  vector&lt;estado&gt; estados_anteriores;
  int n_estudiantes;                             //numero de lo de abajo
  vector&lt;vector&lt;estudiante&gt;&gt; estudiantes;               //lista de todos los estudiantes que faltan por subirse al autobus. En el momento que un alumno se sube al autobus, se le elimina
                                                  //la lista de estudiantes tiene la forma de [parada_de_origen][simplemente el orden en que se metieron]
  </code></pre>
  
  <p>Contructor of estado:</p>
  
  <pre><code>estado(vector&lt;int&gt; prev_esta, int G, vector&lt;estado&gt; estados_ant, int n_estudiantess,
         vector&lt;vector&lt;estudiante&gt;&gt; estudiantess, int parada_destino, bus autobus) : autobus(autobus) {
      prev_estados = prev_esta;
      g = G;
      h = n_estudiantess*4;
      f = g+h;
      estados_anteriores = estados_ant;
      n_estudiantes = n_estudiantess;                //numero que quedan por dejar
      estudiantes = estudiantess;
  }
  </code></pre>
  
  <p>And I want to merge them in a single ordered vector using a pre defined function:</p>
  
  <pre><code>bool comparator(estado a, estado b){
  if(a.getNEstudiantes()==b.getNEstudiantes()){
      if(a.getBus().get_NCarga()==b.getBus().get_NCarga()){
          //Aqui se puede implementar homogeneidad de alumnos en el bus
          if(a.getG()==b.getG()){
              return true;
          }else{
              //Por una cosa que dijo en clase seria mejor poner que se priorice la G mas grande
              return a.getG() &gt; b.getG();
          }
      }else{
          //Cuantos mas niños haya en el bus mejor
          return a.getBus().get_NCarga() &gt; b.getBus().get_NCarga();
      }
  }else{
      //Cuantos menos estudiantes queden por entregar mejor
      return a.getNEstudiantes() &lt; b.getNEstudiantes();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Doing some research I came out with the function "set_union", which must be used this way:</p>
  
  <pre><code>vector&lt;estado&gt; v(10);
  vector&lt;estado&gt;:: iterator it;
  it= set_union(big.begin(),big.end(),small.begin(),small.end(),v.begin(),comparator);    //unirse ordenadamene en v
  big[a]=v;
  </code></pre>
  
  <p>In fact I receive the following building error:</p>
  
  <pre><code>In file included from /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/stl_tempbuf.h:60:0,
               from /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/stl_algo.h:62,
               from /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/algorithm:62,
               from /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/regex:38,
               from /cygdrive/c/Users/dasan/CLionProjects/Heuristica_2_2/bus.h:10,
               from /cygdrive/c/Users/dasan/CLionProjects/Heuristica_2_2/heuristic.h:5,
               from /cygdrive/c/Users/dasan/CLionProjects/Heuristica_2_2/heuristic.cpp:5:
  /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/stl_construct.h: In instantiation of 'void std::_Construct(_T1*, _Args&amp;&amp; ...) [with _T1 = estado; _Args = {}]':
  /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/stl_uninitialized.h:527:18:   required from 'static _ForwardIterator std::__uninitialized_default_n_1&lt;_TrivialValueType&gt;::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = estado*; _Size = long unsigned int; bool _TrivialValueType = false]'
  /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/stl_uninitialized.h:583:20:   required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = estado*; _Size = long unsigned int]'
  /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/stl_uninitialized.h:645:44:   required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, std::allocator&lt;_Tp&gt;&amp;) [with _ForwardIterator = estado*; _Size = long unsigned int; _Tp = estado]'
  /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/stl_vector.h:1352:36:   required from 'void std::vector&lt;_Tp, _Alloc&gt;::_M_default_initialize(std::vector&lt;_Tp, _Alloc&gt;::size_type) [with _Tp = estado; _Alloc = std::allocator&lt;estado&gt;; std::vector&lt;_Tp, _Alloc&gt;::size_type = long unsigned int]'
  /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/stl_vector.h:285:30:   required from 'std::vector&lt;_Tp, _Alloc&gt;::vector(std::vector&lt;_Tp, _Alloc&gt;::size_type, const allocator_type&amp;) [with _Tp = estado; _Alloc = std::allocator&lt;estado&gt;; std::vector&lt;_Tp, _Alloc&gt;::size_type = long unsigned int; std::vector&lt;_Tp, _Alloc&gt;::allocator_type = std::allocator&lt;estado&gt;]'
  /cygdrive/c/Users/dasan/CLionProjects/Heuristica_2_2/heuristic.cpp:83:63:   required from here
  /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/stl_construct.h:75:7: error: no matching function for call to 'estado::estado()'
       { ::new(static_cast&lt;void*&gt;(__p)) _T1(std::forward&lt;_Args&gt;(__args)...); }
  </code></pre>
  
  <p>With my basic understancing of c++ I think that the error is in the line </p>
  
  <pre><code>vector&lt;estado&gt; v(10);
  </code></pre>
  
  <p>With the "(10)" part. In fact if I dont include that, the vector will have no room for store the things inserted and I will receive a Segmentation Error.</p>
  
  <p>What I should do? I appreciate all your help.</p>
  
  <p>EDIT: As @txtechhelp point out, the issue was that my class "estado" doesnt have a default controcutor.</p>
  
  <p>Thanks for the help.</p>