3 ms·
> C++ “solved” the problem of redundant casting and error- > prone size calculations by replacing malloc and free with > new and delete. The corrected C++ ver
by Gupie 13y ago
> C++ “solved” the problem of redundant casting and error-
> prone size calculations by replacing malloc and free with
> new and delete. The corrected C++ version of the code
> above would be:
>
> struct Pod {
> int count;
> int * counters;
> };
>
> int n = 10;
> Pod * pod = new Pod;
> pod->count = n;
> pod->counters = new int [n];
> ...
> delete [] pod->counters;
> delete pod;
The 'corrected C++ version of the code' is actually:
std:vector< int > pod( 10 );
...
I didn't bother reading any further.