Hello,
i'm trying to set up a class, in which I can have an Array which contains names.
The problem is that the number of names(/the size of the array) depends on the input.
I tried stuff like this, which gets an access violation:
can you use a vector? (include <vector> !!)
vector <string> players;
which will grow to fit if you use push_back() method or you can manually give it a size, and you can resize as needed etc. Vector is a 'variable length array' that avoids the C-style memory management.
the same is true in main, strongly consider
vector<vector<CPlayers> > Players2d;
instead of that ** mess.
which you leaked, you did not destroy your 2d construct.
we can show you any of this, but let us know if you can use them and if so, what you want to do (we can guess at it, but precise words from you help).
@OP You could also design and use your own list - a set of nodes/pointers - a stock C++ learning issue. The list stores info about (completely separate) Player objects described in a Player struct or Player class.
PS: If <vector>'s are used the same separation principle applies ...