Re: Why does vector.end() point beyond last element?
From: Gianni Mariani (gi2nospam_at_mariani.ws)
Date: 06/27/04
- Next message: James Dennett: "Re: System-header, header-file, using and ::"
- Previous message: Bob R: "Re: C++ and graphics. [OT]"
- In reply to: as mellow as a horse: "Why does vector.end() point beyond last element?"
- Next in thread: Bob R: "Re: Why does vector.end() point beyond last element?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Jun 2004 21:36:44 EDT
as mellow as a horse wrote:
> You'll probably guess I'm only just learning this stuff so this might be a
> stupid question. Given:
>
...
> Why does b1.end() point 1 memory location past the 4th element?
Because it does !
Some may argue that it makes the applications easier to write.
i.e.
for ( i = begin(); i != end(); ++i )
{
.. stuff with i ..
}
it also makes it easy to detect an empty list...
is_empty = begin() == end();
I was
> getting rubbish until I had a brainwave and tried some fiddly pointer
> arithmetic. Am I missing something?
No.
- Next message: James Dennett: "Re: System-header, header-file, using and ::"
- Previous message: Bob R: "Re: C++ and graphics. [OT]"
- In reply to: as mellow as a horse: "Why does vector.end() point beyond last element?"
- Next in thread: Bob R: "Re: Why does vector.end() point beyond last element?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|