H
Hongyu
Dear all:
I am reading "Thinking in C++" volume 2, p629, and have a question on
the below code:
.......
static void run( ) {
vector<Task *>::iterator it = tasks.begin( );
while (it != tasks.end())
(*it++)->operation( );
}
......
My question here is: why use (*it++)-> for the iterator it? which
indicate that it is a pointer. But from the defination, I only see
vector<Task *>::iterator it = tasks.begin( );, instead of vector<Task
*>::iterator *it; The vector <Task *> only indicate that the vector
contains <Task *> inside, doesn't mean it is a pointer, if from the
defination above, no pointer * is in front of it.
I believe the book is correct. But what's wrong with my understanding.
Any help for clarifying this will be appreciated.
I am reading "Thinking in C++" volume 2, p629, and have a question on
the below code:
.......
static void run( ) {
vector<Task *>::iterator it = tasks.begin( );
while (it != tasks.end())
(*it++)->operation( );
}
......
My question here is: why use (*it++)-> for the iterator it? which
indicate that it is a pointer. But from the defination, I only see
vector<Task *>::iterator it = tasks.begin( );, instead of vector<Task
*>::iterator *it; The vector <Task *> only indicate that the vector
contains <Task *> inside, doesn't mean it is a pointer, if from the
defination above, no pointer * is in front of it.
I believe the book is correct. But what's wrong with my understanding.
Any help for clarifying this will be appreciated.