Re: vector question
From: Howard (alicebt_at_hotmail.com)
Date: 03/18/05
- Next message: Markus Dehmann: "const debug variable optimized away if false?"
- Previous message: Sowen: "Re: how to write bits by using ofstream?"
- In reply to: Kitty: "vector question"
- Next in thread: Kitty: "Re: vector question"
- Reply: Kitty: "Re: vector question"
- Reply: Howard: "Re: vector question"
- Reply: Chris Theis: "Re: vector question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 18 Mar 2005 17:44:04 GMT
"Kitty" <No spam> wrote in message news:423b0fd3$1_2@rain.i-cable.com...
> Hello.
>
> Given vector<Object>, I would like to find the position of an element
> "obj" in this container. What function should I use? Thanks.
>
If I undesrstand correctly, vector is not an "associative" container, so you
can't use find() on it. A simple loop using an iterator (or
const_iterator), and doing whatever comparison you need to check if an item
meets your requirement, should do the trick. (You don't say what you mean
by "an element 'obj'", so I'm guessing you've got some way to identify the
object you want...?)
-Howard
- Next message: Markus Dehmann: "const debug variable optimized away if false?"
- Previous message: Sowen: "Re: how to write bits by using ofstream?"
- In reply to: Kitty: "vector question"
- Next in thread: Kitty: "Re: vector question"
- Reply: Kitty: "Re: vector question"
- Reply: Howard: "Re: vector question"
- Reply: Chris Theis: "Re: vector question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|