arrays that store pointers

U

user

I want to be create an array that stores pointers to objects of a type
that I have created in my program. How do I do this and avoid using a
dynamic array?

Basically I have a pointer to a vertex and I want to store it in an
array that holds pointers to vertices. That is the gist of what I am
trying to do.

Thanks.
 
V

Victor Bazarov

I want to be create an array that stores pointers to objects of a type
that I have created in my program. How do I do this and avoid using a
dynamic array?

If you know how many pointers you need, you just declare the array:

the_type_you_created *pointerarray[howmany];

'howmany' has to be a compile-time constant expression. The array is
not dynamic, but instead is either automatic or static or a member of
another object (and the storage duration is determined by the object).
Basically I have a pointer to a vertex and I want to store it in an
array that holds pointers to vertices. That is the gist of what I am
trying to do.

I see no problem. Perhaps I don't understand fully what you're trying
to accomplish...

V
 

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,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top