WordT * data;
} else {
// make space for the new word
newList = new WordT[wordCount+1];
for (i = 0; i < wordCount; i++) {
newList[i] = data[i];
}
if (data != nullptr) {
delete [] data;
}
data = newList;
valgrind WordCount2
~WordListT() to the header.
WordListT::~WordListT() {
if (data != nullptr) {
delete [] data;
}
}
youve 1
Getting the user action
Performing the user action
corrupted size vs. prev_size while consolidating
Aborted (core dumped)
WordListT(WordListT & other)
WordT * CopyArray(WordT ary[], int size, bool increase) {
WordT * rValue{nullptr};
int i;
int newSize = size;
if (increase) {
newSize++;
}
rValue = new WordT [newSize];
for (i =0; i < size; i++) {
rValue[i] = ary[i];
}
return rValue;
}
WordListT::WordListT(WordListT & other) {
data = CopyArray(other.data, other.wordCount, false);
wordCount = other.wordCount;
current = other.current;
}
WordListT copyOfWords;
...
copyOfWords = words;