There is a lot to talk about here.
has 2 things: a size and a pointer to the memory which was allocated with
, so the data is on the heap. The actual details are a bit complicated, and requires knowledge of templates and Template Meta Programming (TMP), and exceptions.
The whole idea of the Standard Template Library (STL) is to make life easier for coders. The least of it is not having to do manual memory management, and being able to dynamically resize containers with little effort nor knowledge of what the compiler does implicitly. The STL has RAII, move semantics, and has a lot things which make it behave very well.
One of the problems with people new to C++, is that they often think in C not C++. It's an easy trap to fall into, not meant to be a criticism :+) This a big problem problem because people approach things at too low a level, such as wanting to do things with pointers, as opposed to all the good stuff that comes with the STL. There is a school of thought that says: to teach C++, don't
teach them C !
C++ is a multi paradigm language: one can do C style programming; use the STL; do OOP with classes and virtual polymorphism etc; and do template programming and TMP. But doing C style coding when the STL is available is discouraged.
It is possible to do multiple dimension arrays with pointers, it's just the same as in C. But that is tricky to get right, so use an STL container.
gives a ragged array because the inner vector size can vary. There is also
, but one must specify the size at compile time. Also could use
if that suits you better.
Not sure if you have seen these:
There was also an article by Stroustrup about the details of RAII, but I couldn't find it.