• Advertisement

Archived

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

Dynamic sized array of pointers

This topic is 5289 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


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

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
Thats exactly what I mean, but I need an array of pointers, not an array of objects on the freestore.

Pat - Ex nihilo nihilus

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

  • Advertisement