std::vectro - append other vector container?

G

Gernot Frisch

Hi,

how can I append the contents of one vector to another?

std::vector <int> a, b;

a.push_back(3); a.push_back(4);
b.push_back(5); b.push_back(7);

a+=b;
a.append(b);
a.push_back(b);

all doesn't work... Please help.
-Gernot

--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
 
S

Sharad Kala

Gernot Frisch said:
Hi,

how can I append the contents of one vector to another?

std::vector <int> a, b;

a.push_back(3); a.push_back(4);
b.push_back(5); b.push_back(7);

a+=b;
a.append(b);
a.push_back(b);

all doesn't work... Please help.

a.insert(a.end(), b.begin(), b.end());

-Sharad
 
R

Ruslan Abdikeev

Gernot Frisch said:
Hi,

how can I append the contents of one vector to another?

std::vector <int> a, b;

Try insert:
a.insert( a.end(), b.begin(), b.end() );

Hope it helps,
Ruslan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top