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

multi-dimensional array dinamic allocation VERSUS <vector>

P: n/a
I'm a newbie in C++ programming. I bought a book yet and I have
learned by means internet donwloadble materials. I feel not
confortable using multi-dimensional arrays. I simply cannot understand
memory allocation principle. I have got some ideas that require this
one, but only thoughts and no action I have done. Unfortunately, the
Deitel book don't explore this topic well. Vectors? How to use them
insted of multi-dimensional arrays? What benefit do they bring to the
source code? Could you help me on this topics?

thanks,

Roberto Dias
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Roberto Dias wrote:
I'm a newbie in C++ programming. I bought a book yet and I have
learned by means internet donwloadble materials. I feel not
confortable using multi-dimensional arrays. I simply cannot understand
memory allocation principle. I have got some ideas that require this
one, but only thoughts and no action I have done. Unfortunately, the
Deitel book don't explore this topic well. Vectors? How to use them
insted of multi-dimensional arrays? What benefit do they bring to the
source code? Could you help me on this topics?

thanks,

Roberto Dias


C and C++ requires the programmer to manually manage memory allocation
issues (there's no automated garbage collection mechanism unlike in Java or
Python...). Case in point - if you're to use a list of objects that would
change its size on runtime you'd need to allocate memory for object
creation - then destroy them properly upon termination of the program -
else the memory allocated for the said data structure would not be freed. A
knowledge of how pointers work would be needed here.

Vectors are similar to arrays, except that the size of the container isn't
constrained by the declaration. Since it is a standard container class, the
properties of a vector can be manipulated by using the container algorithms
as defined in the STL.

Bjarne Stroustrup's "The C++ Programming Language" discusses much on C++
programming - and is imho a must-have for C++ programmers.
--
Paolo Alexis Falcone
pf******@free.net.ph
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.