I have an array of pointers of CName objects. I have the following constructor which initializes my array to size one. Then when I add an object I grow the array by 1 and add the new object. It compiles fine, however when I try to print them I just get segmentation fault error. Can you look and see if I'm doing anything wrong?
//constructor
Names_Book::Names_Book()
{
    grow_factor = 1;
    size = 0;
    cNames = (CName**)malloc(grow_factor * sizeof(CName*));
    cNames[0] = NULL;
}
void Names_Book::addCName(CName* cn)
{
    int oldSize = size;
    int newSize = size + 1;
    CName** newCNames = (CName**)malloc(newSize * sizeof(CName*));
    for(int i=0; i<newSize; i++)
    {
        newCNames[i] = cNames[i];
    }
    for(int i=oldSize; i<newSize; i++)
    {
        newCNames[i] = NULL;
    }
    /* copy current array to old array */
    cNames = newCNames;
    delete(newCNames);
    size++;
}
 
     
     
    