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:
Code:
vector<Trigger*> triggers
The program also has a vector of pointers to Pad objects, declared like
This seams to work well in most situations and I can access variables in a trigger in a pad.
But I need to iterate through every pad in the vector and every trigger in the vector in pad.
I do it like this:
Code:
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();
}
Everything works fine until the line
Code:
cout << (*triggIt)->getName().c_str();
where I get a segmentation fault.
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