1

I'm wondering how to combine two integer like this

vector <int>  A = {3,4,5};
vector <int>  B = {100,102,103};

and then can we have a fast way or a funtion that can help to attach the vector B to vector A and vector A then look like this :

A = { 3,4,5,100,102,103}
Miku
  • 79
  • 1
  • 7

2 Answers2

2

You can do this using insert of c++

A.insert(A.end(), B.begin(), B.end());

There are further more ways to do that find it here :

Raen
  • 21
  • 3
1

Use std::vector::insert:

std::vector<int> A { 3, 4, 5 };
std::vector<int> B { 100, 102, 103 };
A.insert(A.end(), B.begin(), B.end());
Aykhan Hagverdili
  • 28,141
  • 6
  • 41
  • 93