ANSI C++: Diferences between delete and delete[]
- by Sunscreen
I was looking a snipset of code:
int* ip;
ip = new int[100];
delete ip;
The example above states that: "This code will work with many compilers, but it should instead read:"
int* ip;
ip = new int[100];
delete [] ip;
Is this indeed the case? I use the compiler "Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 11.00.7022 for 80x86" and does not complain (first example) while compiling. At runtime the pointer is set to NULL.
Other compilers behave diferrently? Can a compiler not compain and issues can appear at runtime?
Thanks,
Sun