Mohammed Mounir
Mohammed Mounir

Reputation: 81

Write the required code to create a dynamic one dimensional integer array

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

Answers (1)

Kurumi Gaming
Kurumi Gaming

Reputation: 121

A vector is what you want.

#include <vector>
// some stuff
std::vector<int> A(size);

Upvotes: 1

Related Questions