Saturday, 31 August 2013

Allocate pointer array without using `new`?

Allocate pointer array without using `new`?

Here is my code:
int *arr1 = new int[size]();
int *arr2 = new int[size]();
int *arr3 = new int[size]();
I know, I know: I should be using std::unique_ptr if I need to use
pointers, but I am required by an assignment to use * arrays (using
"dynamic allocation" - I would use std::vector but that's not allowed
either for some reason).
I know using new is bad practice, so is there a way to use a pointer array
without using that keyword or having to do delete later on?

No comments:

Post a Comment