Q:

Copy the array you defined in the previous exercise into another array. Rewrite your program to use vectors

0

Copy the array you defined in the previous exercise into another array. Rewrite your program to use vectors.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <vector>

int main() {
  int ia[10];
  for (size_t i = 0; i != 10; ++i)
    ia[i] = i;

  int ia2[10];
  for (size_t i = 0; i != 10; ++i)
    ia2[i] = ia[i];

  std::vector<int> iv;
  for (int i = 0; i != 10; ++i)
    iv.push_back(i);

  std::vector<int> iv2(iv);

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now