V
Victor Bazarov
Dr. J.K. Becker said:Is there any way to get a pointer to a vector (or the vector itself) if you
only have an iterator of it?
Not portably, no. Why do you need it? If you need a vector, just pass
the vector into your function, you can always get an iterator from it.
[...]
And another, somewhat related question:
The basics:
class Test
{
public:
double d;
void DoSomething(double t);
};
Now in another file I do:
vector<Test> x;
than I push_back lots of stuff into x and at one point do
x.DoSomething(double t);
This is a syntax error, first of all. Second, 'x' is a 'vector'.
'vector' does not have member 'DoSomething'. Do you mean you do
x[someindex].DoSomething(somedoublevalue);
?
Now in the function DoSomething, can I use 'this' in a nifty way to get a
pointer to the vector x?
No. A contained object does not know it is contained anywhere *unless*
you somehow tell the object where it is contained.
[...]
V