As nv3 said, don't do it - the compiler could generate code to do just about anything.
Anyway, rather than worrying about using
why not take the easy, incredibly safe, way out and use
to manage memory for you?
So if you want an array of things that have a default constructor you can use:
std::vector<my_class>( 20 );
to create a
of 20 objects of class
. And you won't have to worry about whether you need to call
. And you can do just about anything you did with a built in array - including indexing past the end if you feel so careless.
So Ash's advice for pain free memory leak detection in C++ is:
- don't manually manage memory
- use stack based/automatic objects wherever you can
- where you can't use them use
Do that lot and you can spend the rest of your programming life with C++ not leaking any memory, never double deleting objects and having all the other "fun" you can have with pointers.