我对开始和结束工作的方式感到有点困惑,他们在我看来是不一致的。当前进和后退时,他们有不同的行为。
vector<Actor *> a;
a.push_back(new Actor(11));
a.push_back(new Actor(22));
a.push_back(new Actor(33));
vector<Actor *>::iterator it = a.begin();
int x =0;
while(a.begin()+x != a.end()){
cout << (*(a.begin()+x)) << "\n";
x++;
}
cout << "\n";
int y = 1; // if this is set to 0 then its a seg fault =/ when I access
while(a.end()-y != a.begin()){
cout << (*(a.end()-y)) << "\n";
y++;
}
输出
0x979a008
0x979a028
0x979a018
0
0x979a018
0x979a028
我怎样才能得到预期的模式
0x979a008
0x979a028
0x979a018
0x979a018
0x979a028
0x979a008