Effective C++ item 16: Use the same form in corresponding uses of new and delete.

Of cause I know delete corresponding to new and delete [] corresponding to new []. But sometimes things are not that simple. Imaging you are fixing a bug and need to delete an object somebody else wrote, for example:

std::string *foo = new Foo;

How will you delete it? Pretty much everyone will write:

delete foo;

But this is not necessary right if you look a little bit further until you come across this line:

typedef std::string Foo[4];

Oops! Foo is actually array of strings. So you need to use

delete [] foo;

So what’s the lesson learned here? Probably it’s good for you to comment your typedefs, and as a people editing other’s code, look a little bit further. But other than that, my suggestion is to use STL library instead of dynamically allocate arrays of objects unless it’s absolutely necassary.

“Effective C++” Third Edition by Scott Meyers.