Item 16: Use the Same Form in Corresponding Uses of new and delete
delete-for-new and delete[]-for-new[].
-
All constructors should use the same form of
newso that destructor may use the correct form ofdelete. -
Don’t
typedefarray type, which may result in mismatchednewanddeleteform if you aren’t careful.
typedef Foo FooArray[4];
Foo *p = new FooArray; // Implicitly call new[].
delete p; // Call delete, not delete[].Aside: Arrays just don’t mix well with modern C++. You should avoid them as much as you can.
