Storing Data in Array inside Class

I don't know if my title is very descriptive, but I will try explain my problem. Please keep in mind that I am a beginner!

I built a class to randomly select 5 objects (fruit in this case) from a pool of 5 different types of objects. The class has 2 procedures. The first randomly selects the 5 objects (I have no problem with this). The second shows (prints out) which 5 were selected (I am struggling).

I can think of a couple ways to do this, but for the sake of nice looking code I want to use an array.

I'm trying to store which object was chose to a 2 dimensional (ie selected_fruit[5][10]). I would then use a for loop to simply print out each character. I initialize in private like this
char selected_fruit[5][10];

then I include it in the constructor

and in function like this

for(int x = 0; x < 6; x++)
random_spin = (rand()%100+1);

if(random_spin <= apple_probability)
selected_fruit[x][10] = "Apple";

I have tried tons of variations of this and nothing is working. I tried sting array instead of char array. I also tried using pointers (which I don't really understand well) like I found in this example.

char *hello[] = { "This", "is", "probably", "what", "you", "want" };

I think this would be the best path to take. But I can't get char pointer to initialize in class/private like it does in the example. I don't think I am able to alter char arrays like I am attempting.

Anyway input would be appreciated. I can't figure out a clever way to get randomly selected object to the print function. I think an array would make for the cleanest code.

Topic archived. No new replies allowed.