P
Prasad
Hi,
I have been using vector::iterators for a while now. This is the first
time I have encountered this problem.
The vector contains one element.
1. vector<GroupSetTemplate>::iterator gstIt;
2. for(gstIt= this->invariantState.getGroupSetTemplates().begin();
gstIt!=this->invariantState.getGroupSetTemplates().end();gstIt++)
3{
4 cout<<"Gst name"<<(*gstIt).getName()<<endl;
5}
Line 4 throws me segmentation fault.
However if I rewrite the above code using vector::at() it works fine.
GroupSetTemplate element = invariantState.getGroupSetTemplates().at
(0);
cout<<"Gst name"<<element.getName()<<endl;
So I know that there is no problem with the element. Am I missing
something ?
I have been using vector::iterators for a while now. This is the first
time I have encountered this problem.
The vector contains one element.
1. vector<GroupSetTemplate>::iterator gstIt;
2. for(gstIt= this->invariantState.getGroupSetTemplates().begin();
gstIt!=this->invariantState.getGroupSetTemplates().end();gstIt++)
3{
4 cout<<"Gst name"<<(*gstIt).getName()<<endl;
5}
Line 4 throws me segmentation fault.
However if I rewrite the above code using vector::at() it works fine.
GroupSetTemplate element = invariantState.getGroupSetTemplates().at
(0);
cout<<"Gst name"<<element.getName()<<endl;
So I know that there is no problem with the element. Am I missing
something ?