Dynamically Growing an Array in C++
问题 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: