For an array you would have to provide an initializer for each element of the array at the point where you define the array.
For a vector you can provide an instance to copy for each member of the vector.
e.g.
std::vector<Foo> thousand_foos(1000, Foo(42));
More Related Contents:
- Invalid operands to binary expression while implementing vector [closed]
- For loop with an array
- Difficulties on atributting a array to another [closed]
- can’t extract data from a structure array c++ [closed]
- How would I implement Arrays into this code
- Initialization of all elements of an array to one default value in C++?
- How to pass a multidimensional array to a function in C and C++
- How to return an array from a function?
- Can placement new for arrays be used in a portable way?
- Printing an array in C++?
- Comparing arrays for equality in C++
- size of array passed to C++ function? [duplicate]
- c++ array assignment of multiple values
- Sorting two corresponding arrays [duplicate]
- Common array length macro for C? [duplicate]
- How do you initialise a dynamic array in C++?
- pointer to array c++
- Finding smallest value in an array most efficiently
- Can std::begin work with array parameters and if so, how?
- How can I make `new[]` default-initialize the array of primitive types?
- Are non dereferenced iterators past the “one past-the-end” iterator of an array undefined behavior?
- What is the use of 0-length array (or std::array)?
- can’t modify char* – Memory access violation
- Braces around string literal in char array declaration valid? (e.g. char s[] = {“Hello World”})
- Multidimensional variable size array in C++
- Function returning array but main showing garbage [duplicate]
- Parse string containing numbers into integer array
- difference between pointer to an array and pointer to the first element of an array
- Array of size defined by not constant variable
- int *array = new int[n]; what is this function actually doing?