Hi,
I'm new to C++, I have the following pointer declaration:
now how can I access, say the first element of the vertex list.Code:list<Vertex*>* v = m->get_vertices();
I appreciate any help that you guys can offer.
Hi,
I'm new to C++, I have the following pointer declaration:
now how can I access, say the first element of the vertex list.Code:list<Vertex*>* v = m->get_vertices();
I appreciate any help that you guys can offer.
std::list has a begin() member function that returns an iterator that points to the first element of the container.
Thanks for the tip. But what if I wanna access other elements, e.g. 3rd element. Do I just set up a counter and make the iterator points to that position?
yes, usually by using a loop.
if you're doing a lot of random access though, you might wanna use a vector instead.