Memory Allocation for Structure / Class

A

akshay4friend

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
 
S

SirMike

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.
 
A

Akshay

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
 

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

No members online now.

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,654
Latest member
LannySinge

Latest Threads

Top