m*****g 发帖数: 226 | 1 stl container use iterators instead of pointers.
however, what if i want to use a pointer to pointers, can i do it with
iterators? how?
for example, with normal pointers, i can do
int *A, *B;
int **P;
if(...) *P = A;
else *P=B;
how to do this with iterators?
thx | h**6 发帖数: 4160 | 2 I think you can use a pointer to an iterator as below:
typdef vector vi;
void main()
{
int input[] = {1, 4, 5};
vi weight = vi(input, input+sizeof(input)/sizeof(input[0]));
vi::iterator it1 = weight.begin();
vi::iterator it2 = weight.end()-1;
vi::iterator *pit = new vi::iterator;
if(1+1 == 3)
*pit = it1;
else
*pit = it2;
int result = **pit;
delete pit;
cout<
} | m*****g 发帖数: 226 | |
|