Q: What is the difference between 'delete' and 'delete[]'?
A: Whenever you allocate memory with 'new[]', you have to free the memory using 'delete[]'. When you allocate memory with 'new', then use 'delete' without the brackets. You use 'new[]' to allocate an array of values (always starting at the index 0).
Code:int *pi = new int; // allocates a single integer int *pi_array = new int[10]; // allocates an array of 10 integers delete pi; pi = 0; delete [] pi_array; pi_array = 0;