STL: Bad Behaviour

| | Comments (0)
We've been arguing at work about whether it's ok to use the & operator while indexing an STL vector. I'm currently working with a compiler that is throwing errors at me for doing it, so I finally has backup for my arguments *sigh*. It's quite easy to learn the 'right' way: Never do: [cpp] // Bad m_vecSound.erase( &m_vecSound[i] ); [/cpp] Do: [cpp] // Good m_vecSound.erase( m_vecSound.begin() + i ); [/cpp] May be obvious to some but apparently not to all. :o

Leave a comment

About this Entry

This page contains a single entry by Andreas Thorsén published on February 4, 2005 4:43 PM.

Clickable errors with gcc makefile projects in Visual Studio .Net 2003 was the previous entry in this blog.

How to calculate a box is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.