Archived

This topic is now archived and is closed to further replies.

patindahat

Dynamic sized array of pointers

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites