resizing vector error !!

I've got this in a class named Poblacion:

vector<Individuo> population;

In other class, I do some operations and I want to do:

Poblacion pob;

pob.population.resize (variable);

And I get this error (2 times):

/usr/include/c++/4.0.0/bits/stl_vector.h: In member function ‘void std::vector<_Tp, _Alloc>::resize(size_t) [with _Tp = Individuo, _Alloc = std::allocator<Individuo>]’:
Algoritmo.H:395: instantiated from here
/usr/include/c++/4.0.0/bits/stl_vector.h:442: error: no matching function for call to ‘Individuo::Individuo()’
Individuo.H:144: note: candidates are: Individuo::Individuo(const Individuo&)
Individuo.H:109: note: Individuo::Individuo(const int&, const int&, const float&, const float&

Why?? Thanks to all
no matching function for call to ‘Individuo::Individuo()

Type Individuo has no default constructor.
but I make a lot of things with this vector and this error never appears... why now? I don't understand the relation between resize and the default constructor :S
From this site's reference section:

Notice that this function changes the actual content of the vector by inserting or erasing elements from the vector; It does not only change its storage capacity. To direct a change only in storage capacity, use vector::reserve instead.

http://www.cplusplus.com/reference/stl/vector/resize/
Let's say you have a vector of Individuo with 2 elements. You call resize with a parameter of 4. 2 objects of Individuo must be default constructed. Why didn't you have this problem with other types? Perhaps those types have a default constructor. If individuo has a constructor that takes args then it might not have a default constructor. Classes always have a default constructor unless you manually write one.
Topic archived. No new replies allowed.