Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > std::vectro - append other vector container?

Reply
Thread Tools

std::vectro - append other vector container?

 
 
Gernot Frisch
Guest
Posts: n/a
 
      07-28-2004
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


 
Reply With Quote
 
 
 
 
Sharad Kala
Guest
Posts: n/a
 
      07-28-2004

"Gernot Frisch" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
 
Gernot Frisch
Guest
Posts: n/a
 
      07-28-2004


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


Ah... Thank you!


 
Reply With Quote
 
Ruslan Abdikeev
Guest
Posts: n/a
 
      07-28-2004
"Gernot Frisch" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
the address of list.append and list.append.__doc__ HYRY Python 10 09-26-2007 09:41 AM
const vector<A> vs vector<const A> vs const vector<const A> Javier C++ 2 09-04-2007 08:46 PM
Initializing vector<vector<int> > and other vector questions... pmatos C++ 6 04-26-2007 05:39 PM
Free memory allocate by a STL vector, vector of vector, map of vector Allerdyce.John@gmail.com C++ 8 02-18-2006 12:48 AM
how the vector is created, how to pass vector to webservices method apachesoap:Vector Rushikesh Joshi Perl Misc 0 07-10-2004 01:04 PM



Advertisments