By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,234 Members | 1,872 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,234 IT Pros & Developers. It's quick & easy.

Memory Allocation for Structure / Class

P: n/a
Hi,
I am creating a structure / class having data type like

{
DOUBLE x;
DOUBLE y;
DOUBLE z;
}POINT3D;

now my data is stored in a file..so i need to create buffer to read
this points one by one...how i suppose to allocate memory for this
using NEW..i DONT want to create predefined fixed length array for this
as i dont know how many points are there in a file but i want to
allocate memory as i get next set of point. Can i use vector<> for such
type ? or is there any way to dynamically allocate memory to create
infinite or expandable array ? plz help
thanx in advance.

Akshay

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ak***********@yahoo.com wrote:
now my data is stored in a file..so i need to create buffer to read
this points one by one...how i suppose to allocate memory for this
using NEW..i DONT want to create predefined fixed length array for this
as i dont know how many points are there in a file but i want to
allocate memory as i get next set of point. Can i use vector<> for such
type ? or is there any way to dynamically allocate memory to create
infinite or expandable array ? plz help
thanx in advance.

Use vector<>, IMHO the best way to do it. You can expand it, erase
elements, sort when you want - without much work.

--
the code is my strength
SirMike
Jul 23 '05 #2

P: n/a
Hi,
Can anyone give me short example for this...I am using Vc++ 6.0.. how
to use vector to declare such type of array of structure / class ..
thanx
Akshay


SirMike <sirmike@FUCK_SPAMMERSpoczta.onet.pl> wrote in message news:<cu**********@korweta.task.gda.pl>...
ak***********@yahoo.com wrote:
now my data is stored in a file..so i need to create buffer to read
this points one by one...how i suppose to allocate memory for this
using NEW..i DONT want to create predefined fixed length array for this
as i dont know how many points are there in a file but i want to
allocate memory as i get next set of point. Can i use vector<> for such
type ? or is there any way to dynamically allocate memory to create
infinite or expandable array ? plz help
thanx in advance.

Use vector<>, IMHO the best way to do it. You can expand it, erase
elements, sort when you want - without much work.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.