473,474 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Memory Allocation for Structure / Class

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
2 2822
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: John | last post by:
Following is a simple class: class myclass{ public: int AA; char BB; } The size of an object of myclass is 4*20000+10000. That is to say, an object of myclass occupies the memory of...
62
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image();...
7
by: toton | last post by:
Hi, I have a STL vector of of characters and the character class has a Boost array of points. The things are vector<Characterchars; and class Character{ private: array<Point,Npoints; }; Now...
2
by: nayannovellus | last post by:
As per my knowledge i know that when a structure is defined, no memory is assigned to its members but when a variable of that structure is declared memory is allocated and also this allocation takes...
18
by: MajorSetback | last post by:
I am using the Redhat version of Linux and GNU C++. It is not clear to me whether this is a Linux issue or a C++ issue. I do not have this problem running the same program on Windows but...
24
by: Ken | last post by:
In C programming, I want to know in what situations we should use static memory allocation instead of dynamic memory allocation. My understanding is that static memory allocation like using array...
3
by: ranjeetasharma81 | last post by:
Hi all, I have a big C-cod, in which there are lots of dynamic memory allocation used. I want to replace dynamic memroy allocation by static arrays. The following are the problems that i am...
5
by: cham | last post by:
Hi, I am working on c++ in a linux system ( Fedora core 4 ), kernel version - 2.6.11-1.1369_FC4 gcc version - 4.0.0 20050519 ( Red Hat 4.0.0-8 ) In my code i am creating a vector to store...
12
by: David Given | last post by:
I have a situation where I need to be able to allocate chunks on unmapped virtual memory. Because the memory I'm allocating isn't mapped, I can't use a normal memory allocator, as most of them...
13
by: eternalLearner | last post by:
i am writing an client application that connects to the server and then sends data to server. but, the problem is that i get a java.net.ConnectException: Connection refused error. The code i have...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.