I created a struct with two fields of type Point3f
(which is inherited from another header).
struct C_Cell {
Point3f min, max;
};
then I created a vector of C_Cell
std::vector< C_Cell> grid;
and I have filled through grid.push_back(c)
where c
is a C_Cell
.
Now, when I try to iterate the vector, through
for (std::vector<C_Cell>::iterator it = grid.begin() ; it != grid.end(); ++it)
during debugging, the type of it isn't C_Cell
but Point3f
, which is the type of the field, moreover empty.
How can I iterate correctly, in such a way to obtain a single element of type C_Cell
?
Thanks ( and sorry for my english! :) )
You have to dereference the iterator and use it like
(*it).min
or
(*it).max
or, without de-referencing,
it->min
The type of the dereferenced iterator (*it)
SHOULD be C_Cell
, as that's how iterators work, their operator*
returns a reference to an object of the underlying type of the container. Iterators behave very much like regular pointers (although they are not regular pointers, but proxy classes), you can increment/dereference etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With