Vector iterators

后端 未结 7 1032
再見小時候
再見小時候 2021-01-29 04:45

I have a the following code.

vector* irds = myotherobj->getIRDs();//gets a pointer to the vector
for(vector::iterator it = ir         


        
7条回答
  •  梦毁少年i
    2021-01-29 05:24

    Dereference the iterator to get a reference to the underlying object.

    vector* irds = myotherobj->getIRDs();
    for(vector::iterator it = irds->begin(); it != irds->end(); ++it)
    {
        IRD& ird = *it;
        ird.doSomething();
        // alternatively, it->doSomething();
    }
    

提交回复
热议问题