Dynamic Allocation

I am using to new operator to dynamically allocate memory for a multi-dimensional array ... What all other types of methods in dynamic allocation can I use besides the new operator ??? I am reading the data from a file which will store the content in the array and then use it later for computation ... The length of the array depends on the number of buses (power system) in the data file ... I was (with the new operator) reading the data file initially to find the number of buses and then using that number of memory allocation to the multi-dimensional array ...
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>> What all other types of methods in
>> dynamic allocation can I use besides the
>> new operator
You can use malloc().  But why would you want to?

Is there any reason why you don't want to use new?

As a tottally different approach, you may wish to use a container class to store the data.  For example the STL vector<> class.

Note For 10 pts, you should be expecting a 1 or 2 word answer.  
You could use malloc or calloc . malloc is unitialized allocation and calloc is initialized. But new is the recommended mode of memory allocation in c++.
calloc is "initialized" only in the C, not C++, sense of initialized.  If the data to be allocated has a constructor, calloc does not call it.  new does.
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

arindam042099Author Commented:
Okay this is what I have to do:
I am writing this program for a power system which has say three transmission line and one transformer ...
frombus tobus impedance
1          2    .3
2          3    .4
3          4    .5
and the transformer data
5          3    .2

I want to allocate memory to a two dimensional array such that it becomes a 5*5 matrix ... when I do "new" I will have to read from the line data file and pick 4 and then search from the transformer data and pick 5 ... As you can see I want to avoid this searching method to size my array using the new operator ... and not only that I am talking about say 100 buses ...
I want the array to resize if I remove something out ... I DO NOT THINK I CAN DO THAT USING THE new operator ...
Use the STL vector<> class.  It is like an array but can resize ar run-time and it has features for inserting items within the array or removing them from the array.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arindam042099Author Commented:

Can you provide me with an example

This is a 10 point question!  You got a more than 10 point answer to the original quesiton and a more than 10 point answer to a second question.  For 10 points you should ask a a question that deserves a Yes/No answer.  You should not be expecting source code.

In any case the STL is bejond the scope of ANY question.  It is well documented in many books, I recommend Bjarne Btroustrup's "The C++ programming Language"

vector< vector<double> > Matrix;

Matrix[0][0] = 1;
Matrix [0][1] = 2

arindam042099Author Commented:
Thanks for the help ... Sorry about the points ... When you mentioned STL earlier I had no clue what that was ...
Standard Template Library--STL.  A good C++ book will get you started.  Expect to spend a few hours learning it.  A lifetime mastering it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.