Adding a local Variable to a Vector Question
Hi,
I'm a C programmer developing a basic audio mixer in C++. The program consists of multiple audio tracks each containing multiple audio clips. I'm running into problems with the audio clips which I add to a vector class variable as follows:
Code:
void AudioTrack::addClip(const char *infilename, unsigned long startIndex) {
// Add the clip to the clip vector.
AudioClip* ac = new AudioClip(infilename, startIndex);
ac->setClipNumber(clipNumber);
audioClipVector.push_back(ac);
...
When the program starts I add a couple of tracks and clips for testing. This seems to work OK. However once the program starts running the first track's clip vector shows incorrect values. Here's an example:
Number of clips in Track 0: 2
Number of clips in Track 1: 1
Number of clips in Track 2: 1
Number of clips in Track 0: 4062199338
Number of clips in Track 1: 1
Number of clips in Track 2: 1
I wanted to check that the problem didn't lie in the way I was adding a local clip variable to the class variable vector - is that OK? Or is this the cause of the problem?
Cheers,
Chris