Reputation: 81
I'm not sure how to answer this question or what it ask exactly for.
Q:Write the required code to create a dynamic one dimensional integer array.
So does it ask just to make dynamic 1D array like this:
new int [5]
or
new int [size]
or it ask for another answer like this one:
int size = 5;
int *ptr;
ptr = new int[size];
Thank you.
Upvotes: -2
Views: 113
Reputation: 121
A vector is what you want.
#include <vector>
// some stuff
std::vector<int> A(size);
Upvotes: 1