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