Dynamic table as a structure member

Hello,
is it possible to make something like that?
struct type_name
{
char Status[i];
string Status[j];
.
.
} object_names;
The problem is I dont know how many statuses my object will have. Is it possible to make it in an dynamic array?
Yes.

The easiest way to achieve this is using std::vector instead of C-style arrays.

If you're really fixated on using C-style arrays, then you'll need to use dynamic allocation (i.e. new) to allocate memory for those arrays at the point where you know how many elements those arrays will have. And, of course, you'll need to free that memory (using delete) when you no longer need it.

But you're much better off using std::vector, which will handle the memory management for you.
Yhym, but I think there wont be a moment when I ll know how many statuses there will be. Their number will change often. Okey I read a bit about vectors will study it a bit more so I can use it ;) Thanks mate.
Sounds like a vector is definitely what you want than. They manage their own memory as you add more elements to them, and you if you need to resize them to a specific size, then that's easy too.
Topic archived. No new replies allowed.