Hi,
Perhaps you can help me with a problem I have, and which I can't solve...
First of all , I have two classes Pad and Trigger. Pad contains a vector of pointers to Trigger objects declared like:
The program also has a vector of pointers to Pad objects, declared likeCode:vector<Trigger*> triggers
This seams to work well in most situations and I can access variables in a trigger in a pad.Code:vector<Pad*> pads
But I need to iterate through every pad in the vector and every trigger in the vector in pad.
I do it like this:
Everything works fine until the lineCode:vector<Pad*>::iterator padIt; for (padIt = pads.begin(); padIt != pads.end(); padIt++) {vector<Trigger*>::iterator triggIt = (*padIt)->triggers.begin(); for( ; triggIt != (*padIt)->triggers.end(); triggIt++ ) {cout << (*triggIt)->getName().c_str();}
where I get a segmentation fault.Code:cout << (*triggIt)->getName().c_str();
I don't know what is wrong. I can access member methods of triggers when not using iterators like this, but not when I use it like this. The thing that got me thinking is that (*padIt) works fine but I can't access (*triggIt) above!
Is there any obvious wrong with my code here or do you want more of it?
Thanks
Fisherking



LinkBack URL
About LinkBacks



