Pointer to pointer

C

cbaby

What is the most elegant way to allocate memory to pointer to pointer
using 'new'?

I want to make a dynamic array of pointers, basically.
 
I

Ian Collins

What is the most elegant way to allocate memory to pointer to pointer
using 'new'?

I want to make a dynamic array of pointers, basically.
int** pp = new int*[2];

pp[0] = new int[10];
pp[1] = new int[10];
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

What is the most elegant way to allocate memory to pointer to pointer
using 'new'?

I want to make a dynamic array of pointers, basically.

int** parray = new int*[size];
 
J

Juha Nieminen

What is the most elegant way to allocate memory to pointer to pointer
using 'new'?

I want to make a dynamic array of pointers, basically.

Regardless of what is the "most elegant" way of creating an array of
pointers with *new*, I think that the most elegant (and safe) way of
creating an array of pointers is to use std::vector instead of new.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top