new[] / delete[] and throwing constructors / destructors in C++
问题 What happens, in the following code, if construction / destruction of some array element throws? X* x = new X[10]; // (1) delete[] x; // (2) I know that memory leaks are prevented, but additionally: Ad (1), are the previously constructed elements destructed? If yes, what happens if destructor throws in such a case? Ad (2), are the not-yet-destructed elements destructed? If yes, what happens if destructor throws again? 回答1: Yes, if the constructor of x[5] throws, then the five array elements x