Bidimensional array of mixed type?

Hello everyone,

i'm new to this forum. Trying to master the c++.

Here's my first question:

How can i create a bidimensional array that contain both integer and string?

Assuming i want to create the following

myArray [100][6]

where the first colum of the array contains only numbers, while the second one contains a maximum of 6 descriptions for every elements?

Thank you in advance
I think you should use a single-dimension array containing a user-defined structure.
http://www.cplusplus.com/doc/tutorial/structures/
I think you should use a single-dimension array containing a user-defined structure.

This. This is exactly the way to go about it.
Thank you both.

I tried and it works nicely.

Now, assuming i wan to put the descriptions for every elements, when i want, during the execution, would be a good idea to create a class for this?

Thank you
what do you mean by "put the descriptions"? Do you mean get at them, or set them?
Well, there's a lot in common between a struct and a class, as far as I'm aware the only significant difference is the default of public for a struct and private for a class, so converting from a struct to a class is pretty much a non-issue.

@mutexe

I would like to initialize the descriptions one for all items, then be able to set/get any items of the array of struct.

Topic archived. No new replies allowed.