I have listed your options and my own in general order of usability. Note that all the options have their uses. Some are just more rare.
using an STL container
This would in almost all cases be the wisest thing to do. Examples of STL containers are std::vector
and std::list
. If you're like me you might feel that using C style arrays will gain you better performance. This is not necessarily the case. For dynamic size arrays and in some cases even fixed size arrays. The STL containers have equal or better performance to C style arrays.
If you want to know which STL container to use. You might want to have a look at this page.
private Worker[] m_workerarray;
This is the only one I would ever recommend using next to the STL containers. Note that this will only work for a fixed size array. If you have an array with a fixed size, or you intent to make a circular buffer. This is might be the array you would want.
private Worker *m_workerarray;
A normal pointer in general should only be used for objects that might be null and are created dynamically. And even then there are safer ways to do this. I would strongly discourage using them as arrays. Unless you want a very high performance, dynamic array, tailor made to the occasion. An in STD container in general has equal or better performance for most usages.
private Worker **m_workerarray;
This is useful for a so called two dimensional matrix. However, even when using this, in a lot of cases it's not recommended. Since a two dimensional matrix requires several memory jumps. In general I would avoid double pointers unless you really know what you're doing.
Note:
//I think it´s better for every solution to
//store the Array lenght
private Worker *m_workerarray;
It's not just better, it's imperative for every solution you handed. The only exception being the fixed size array ([]
).