3 ms·
Deep C and C++: How much do you really understand?
- willvarfar 15y agoA(int sz) { sz_ = sz; v = new B[sz_]; } ~A() { delete v; } Surely if the allocation of v fails, the destructor will delete some wrong memory pointed at by an unintialised v? The pain of not using initialiser lists?
- DerekL 15y agoNo. If the allocation fails, it throws an exception, and the destructor isn't called.
- duncan_bayne 15y agoI thought 'excellent' ... then saw [scribd] and thought 'meh'.