const int NUM_DIGITS = 7; int pin1[NUM_DIGITS] = {2, 4, 1, 8, 7, 9, 0}; int pin2[NUM_DIGITS] = {2, 4, 6, 8, 7, 9, 0}; int pin3[NUM_DIGITS] = {1, 2, 3, 4, 5, 6, 7}; - Which one, there are three of them. Also, what have you tried to do, already.Sam Varshavchik– Sam Varshavchik2016-03-07 02:19:21 +00:00Commented Mar 7, 2016 at 2:19
Add a comment |
1 Answer
std::vector defines a constructor that takes in two InputIterators and a default allocator with
template <class InputIterator> vector (InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type()); So you can just create a vector from an array like so,
std::vector<int> vec(pin1, pin1 + NUM_DIGITS); 1 Comment
Tony Delroy
Good answer. Also noteworthy that if the array versions aren't needed for anything you can construct only vectors a la
std::vector<int> pin1 = {2, 4, 1, 8, 7, 9, 0}; etc. (= being optional).