How to allocate an array whose elements are 'deque', through pointer in C?

14 Views Asked by At

Standard way of allocating and array of 'int' type through pointer

int *ptr = (int*) calloc(1, sizeof(int));

I want to allocate an array of 'deque' type through pointer.

I tried the following

std::deque<int> *ptr = (std::deque<int>*) calloc(10, sizeof(std::deque<int>));

However, doesn't work.

I need this because the range of 2nd index (j) is dependent on the specific value of the 1st index (i). The range of 2nd index (j) is obtained during computation. For example,

i=0; j=(0,2)
i=1; j=0
i=2; j=(0,6)

etc.

I'm trying with pointer because, it needs to passed as an argument of a function where the range of 2nd index (j) would be computed.

How could I achieve it?

0

There are 0 best solutions below