On 10/6/07, Saurabh Jain <[EMAIL PROTECTED]> wrote:

> > > In a main I have: vector<s> vs;
> > > And I am using an iterator(vector<s>::iterator vsitr) to traverse
> the vector. What I want to know is how to assign the struct s* next of
> the structure using this iterator.
> > >
> > you're attempting to put a "link" in a struct which is held in a
> > vector?  why??
>
> Because I am traversing on a design(you can view it as a graph). So I
> need to have a link of previous nodes and the next nodes in some case.
>  Out of all the nodes stored in a vector.

I think the point Victor is making is that with the rich set of
container classes in C++ (including the vector class), using a linked
list in this fashion is, IMHO, rather silly and redundant, and make
for some ugly code on top of that. The vector class provides a lot of
the same functionality (more, actually) than a linked list.

> >  (there are some
> > things that C requires you to do that just get in the way in C++)
>
> I would love to do that, but best is not the feasible option always! :(

Why not? Usually the simplest solution *is* the best one. I feel sorry
for the person that has to debug a statement like:

struct s* next = &(*vsitr);

-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
    If I were to divulge it, it would overturn the world."
               -- Jelaleddin Rumi

Reply via email to