A
Adam Hartshorne
Hi All,
I have the following setup. Two 'std::vector's which i iterate through in a
for (iterate through vector1 of types X) {
for (iterate through vector2 of types Y) {
f(x)
}
}
loop using the vector iterators.
Ok well f(x) calls another function, and i want to pass pointers to the
elements in the two vectors that the current iterators point at to this
function.
Well i know that the iterator class is basically just a pointer to the
position in the vector anyway. However I want f(x) to remain general and
take a pointers to a type X and a type Y as arguments, rather than two
iterators.
Ok so my question is what do i pass? Is it something like
f(&(*IteratorX), &(*IteratorY))? Or is there a better way.
If my f function took references as arguments, how if at all can i set a
variable contained in X which is a pointer to type Y to the argument of
the function f which is a type Y? i.e. an element of type X in the
vector of type X's now contains a pointer to an element in the vector of
type Y's contained in the main method!
Adam
I have the following setup. Two 'std::vector's which i iterate through in a
for (iterate through vector1 of types X) {
for (iterate through vector2 of types Y) {
f(x)
}
}
loop using the vector iterators.
Ok well f(x) calls another function, and i want to pass pointers to the
elements in the two vectors that the current iterators point at to this
function.
Well i know that the iterator class is basically just a pointer to the
position in the vector anyway. However I want f(x) to remain general and
take a pointers to a type X and a type Y as arguments, rather than two
iterators.
Ok so my question is what do i pass? Is it something like
f(&(*IteratorX), &(*IteratorY))? Or is there a better way.
If my f function took references as arguments, how if at all can i set a
variable contained in X which is a pointer to type Y to the argument of
the function f which is a type Y? i.e. an element of type X in the
vector of type X's now contains a pointer to an element in the vector of
type Y's contained in the main method!
Adam