Dynamic sized array of pointers

Started by
4 comments, last by patindahat 20 years, 8 months ago
How do I make a an array of pointers with a dynamic size? Pat
Advertisement
what programming language are you using?

if c++, use the STL vector class:

vector <variableType *>;

do a google search for "STL tutorial" for info on using the STL. there may also be some tutorials on this site.

if java, use the built in Vector class. (you can look up the functions and whatnot on java.sun.com. look for the API documentation for whatever version of java you are using.


if you want to go the reinvent the wheel method, read about Linked Lists (some form of google search should land you a nice tutorial on that subject)

-me

[edited by - Palidine on July 28, 2003 10:00:16 PM]
Thanks, I didn''t want to have all that extra garbage for a buncha pointers, but I guess I have no choice.

Pat - Ex nihilo nihilus
If you mean dynamic by creating an array of a non-constant size but only once, you can do something like

int* array = new int[size];

Be sure to call delete[] on it when you are done.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Thats exactly what I mean, but I need an array of pointers, not an array of objects on the freestore.

Pat - Ex nihilo nihilus
a pointer is just another object..

typedef int* IntPointer;

IntPointer* intPointers = new IntPointer[sizeOfIntPointerArray];


and vector<int*> doesn''t really have overhead if used right.

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

This topic is closed to new replies.

Advertisement