0
我從位於鏈接列表中的項目獲取一些地址時遇到了一些麻煩。而不是在for循環開始時創建和初始化迭代器地址,我想要查看列表中實際數據的地址。這可能沒有創建我自己的列表實現?這裏是我已經得到的代碼塊,但顯然它不是我想要的方式工作。查找由鏈接列表鏈接的數據的各個地址。 C++
int j = 0;
testIntList.resize(100);
for (list<int>::iterator i = testIntList.begin(); i != testIntList.end(); ++i) {
*i = j*j;
int * k = &(*i);
cout << "the value of the iterator is " << *i << " and the address of the iterator is " << &i << "and the address of the pointer is " << *k << endl;
j++;
}
我以這種方式使用k來嘗試獲取迭代器的值的地址的內存中的實際指針。任何幫助將非常感激。
你已經擁有了 - 它是'k'。 – jrok 2013-02-26 23:20:47