Is this the right way to delete dynamic pointers? If so, how the <bleep> does delete [] age; work? I read a bunch on dynamic pointers and new and delete. I can't visualize/understand/see how that piece of code works.
4
Enter age: 10
Enter age: 20
Enter age: 30
Enter age: 40
age 1: 10
age 2: 20
age 3: 30
age 4: 40
deleteing age : 1
deleteing age : 2
deleteing age : 3
deleteing age : 4
age 1: 4063632
age 2: 4063632
age 3: 30
age 4: 40
Process returned 0 (0x0) execution time : 12.891 s
Press any key to continue.
You should have exactly 1 delete[] for every 1 new[]. If you only new[] once (to allocate space for age), then you only delete[] once (with delete[] age;).