Link to home
Start Free TrialLog in
Avatar of ambuli
ambuliFlag for United States of America

asked on

Question on using Vector iterator

Hi Experts,

I am using the following function to open numbers of file descriptors stored in a vector.  When I run the program, it crashes on this function.  If I check the size of the vector, it says 3.  But, the loop seems to go more than 3 times before crashing.  Can you help me resolve this.  Thank you.

typedef vector<SomeObject> ObjectsVector_t;
typedef ObjectsVector_t::iterator ObjectsVectorIter_t;

bool Reader::openObjects()
{

    cout << "Size is = " << _objectsFactory->getObjectVector().size() << endl;
    for (PPSObjectsVectorIter_t iter = _objectsFactory->getObjectVector().begin(); iter != _objectsFactory->getObjectVector().end(); iter++)
    {
        (*iter).openFd();
    }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ambuli

ASKER

Thanks Evilirix.  I was doing the initialization in the getObjectVector() incorrectly.  Once I resolved that it works.  Thanks.