arrays that store pointers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • user@domain.invalid

    arrays that store pointers

    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.

  • Victor Bazarov

    #2
    Re: arrays that store pointers

    user@domain.inv alid wrote:[color=blue]
    > 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?[/color]

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

    the_type_you_cr eated *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).
    [color=blue]
    > 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.[/color]

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

    V

    Comment

    Working...