Vector creation in c++

Asked

Viewed 36 times

0

What did the new int[2] in

int* vetor = new int[2];

  • A memory area will be allocated that holds 2 int and vector will point to the beginning of this area.

  • It is a form embedded in the malloc(2 * sizeof(int)) language, which is how it would be done in C.

1 answer

2

It means that you are creating a 2 position vector, the value within the brackets indicates the size you want to use for vector creation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.