hya*_*g51 2 c++ gdb iterator vector
我有一个向量vector<int> myvecotr。假设myvector={p1,p2,p3,p4}我需要阅读(p1, p2), (p2,p3),(p3,p4)。
int t1,t2;
for(vector<int>::iterator it=myvector.begin(); it!=myvector.end();++it){
t1=*it;
t2=*(it+1); // the question is here ?
}
Run Code Online (Sandbox Code Playgroud)
当我使用gdb调试它时,
(gdb) p *(it+1)
(gdb) Attempt to take address not located in memory
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是,为什么*(it+1)有时不起作用,但是++it起作用?
任何帮助将不胜感激。
| 归档时间: |
|
| 查看次数: |
2938 次 |
| 最近记录: |