Board index » cppbuilder » Vector Insert

Vector Insert


2006-04-14 08:42:07 PM
cppbuilder97
Hello,
i wanna insert an element into a vector but the position i like. for example
, like in arrays:
int i = 5;
Array[i] = 10; ----->i wanna do this in vectors
How can i do it?
thanks
 
 

Re:Vector Insert

On Fri, 14 Apr 2006 15:42:07 +0300, Cenk wrote:
Quote
How can i do it?
Actually, what you're describing is assigning to an existing value.
For that, you can use [] just like with static arrays.
but check the insert() and at() methods
--
Liz
Please check the newsgroup guidelines and general netiquette
info.borland.com/newsgroups/guide.html
info.borland.com/newsgroups/guide.html
info.borland.com/newsgroups/netiquette.html
 

Re:Vector Insert

"Cenk" < XXXX@XXXXX.COM >wrote in message
Quote
int i = 5;

Array[i] = 10; ----->i wanna do this in vectors
You do it in exact same way. The std::vector container has an '[]' operator
implemented, ie:
std::vector<int>vec;
// add at least 6 items to the vector, then...
vec[5] = 10;
Gambit
 

{smallsort}