Array Question

This is probably a newbie question, but I can't work it out. 

I had an array of Strings in the AudioProcessor of my plug-in.  It was causing problems.  I'd declared it in a very C style way (I normally program microcontrollers in C .... C++ is a bit awesomely complex in comparison): 

class ... {

private:

String p[100]; 

}

The plugin would open once just find, but the second time caused a bad access error somewhere way down in the bowels of the juce library, when a reference count was getting decremented. 

Replacing it with the StringArray from JUCE has fixed the problem, but I can't explain why it was broken.  I'm assuming that when I create a big array of Strings like this 100 constructors get called, and then when the AudioProcessor gets deleted 100 destructors will get called.  

The specific code that was causing the error was: 

    String enumElementName = baseTag.toLowerCase() + "_" + tag.toLowerCase();

    p[i] = enumElementName.replace(" ", ""); // << this crashed(!)

There's obviously some terrible gap in my understanding.  Would I expect to get EXC_BAD_ACCESS here, and why? 

Use StringArray

 

Rail

Already done.  I'm loving StringArray.  But why did my naive approach fail? 

Most likely by using an array index that's out-of-bounds.

I did check that :)  It was indexing number 17 of 200 at the time. 

I just wondered if there was something fundamental that would have prevented it from working.  I ran some tests and I can't see why it should have died like that.  

Thanks though! J.