Why the these constructors produces different result?
The first constructor produces random result each time (in a vector).
The second constructor produces same result every time (in a vector).
(2) fill constructor
Constructs a container with n elements. Each element is a copy of val (if provided).
val
Value to fill the container with. Each of the n elements in the container will be initialized to a copy of this value.
Member type value_type is the type of the elements in the container, defined in vector as an alias of its first template parameter (T).
For the second, you provided 'val' in the first you didn't. In the second one, that's basically asking it to initialize all elements to be a copy of the one you sent in.
But what do you mean by default value? It is the constchar &strength ?
I originally wanted the user to be able to choose the difficulty level (weak,norm,strong) before entering the number of Human (before fighting with enemy).
Using the first way I did, I was able to complete the whole fighting simulation using vectors. Now I just wanted to add new "features" to the program and the same time learning more C++.
No. Just make an empty vector. Then push new ones in as you create them. You can push anything you want into it. It just creates copies when you give it an initial value upon creation.
Like what cire did. That will create 3 different ones, all created with 'strong'.
But notice, the vector is declared std::vector<Human> hu;
An empty vector with no initial values. After that the vector is filled up.