dynamic array or STL vector
From: Vasileios Zografos (noone_at_nowhere.net)
Date: 11/30/03
- Next message: Chris Dams: "Re: NEWBIE: compilation trouble!!!"
- Previous message: David Fisher: "Re: Virtual function 'BasicMidReader::~BasicMidReader()' conflicts with base class 'base 'TMemoryStream'"
- Next in thread: Rob Williscroft: "Re: dynamic array or STL vector"
- Reply: Rob Williscroft: "Re: dynamic array or STL vector"
- Reply: Victor Bazarov: "Re: dynamic array or STL vector"
- Reply: lilburne: "Re: dynamic array or STL vector"
- Reply: Jon Bell: "Re: dynamic array or STL vector"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Nov 2003 00:20:31 +0000
Hello,
I have a function that generates some values (e.g. vertices in 2d space)
the number of which I dont know. So, it could generate 20 vertices, 100
vertices, or even 1 vertex.
void generateVals()
{
....
//generate some values
...
}
What I want to do is store these values as they are generated.
I thought of using something like int *data = int[num_of_vertices] but I
will not know the num_of_vertices until after the generateVals()
function has finished, and when the function has finished I wont be able
to get/store the values any more.
I thought of using a dynamic linked list (such as the STL vector) and
after the generateVals function has finished to copy the values back to
the dynamic array *data (I need this in order to pass the values into
another function that uses int * arrays as input).
Anyways, my question is. Is there a more elegant way to do this by using
a dynamic array? or a linked list is the only way?
Thank you
Vasileios
P.S.
Some people might say that this posting is a bit of topic and should be
sent to a programming newsgroup, but I am looking for an answer specific
to c++ , so if you please know something do tell me.
- Next message: Chris Dams: "Re: NEWBIE: compilation trouble!!!"
- Previous message: David Fisher: "Re: Virtual function 'BasicMidReader::~BasicMidReader()' conflicts with base class 'base 'TMemoryStream'"
- Next in thread: Rob Williscroft: "Re: dynamic array or STL vector"
- Reply: Rob Williscroft: "Re: dynamic array or STL vector"
- Reply: Victor Bazarov: "Re: dynamic array or STL vector"
- Reply: lilburne: "Re: dynamic array or STL vector"
- Reply: Jon Bell: "Re: dynamic array or STL vector"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]