0
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}; 
1
  • Which one, there are three of them. Also, what have you tried to do, already. Commented Mar 7, 2016 at 2:19

1 Answer 1

1

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); 
Sign up to request clarification or add additional context in comments.

1 Comment

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).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.