stack passing data to a pointer array help

Hey guys so i'm trying to make a mini game for my coursework.
I'm trying to create a "bag"(an array) to store the "loot" items a player selects during players choise.
Im trying to make the bag something along the lines of:

string *Bag[6]
Bag = &(chest.top.Name);
but i cant seem to get my head around how im meant to be doing this correctly. I'v read loads online but i think iv hit that stupidity wall that keeps tripping me up haha.

please can someone tell me how to create a pointer array that will store the loot item from the top of the stack called chest.

#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
#include <stack>
#define LootNumber 14
using namespace std;

// the 3 arrays stand for the 3 stats of each item
string NameOption[] = { "Stone", "Leather Gloves", "Dragon Gauntlets", "Chair Leg", "Dragon Scale Helmet", "Pebble", "Rusted Breastplate", "Dragon Breastplate", "Empty Bottle", "Chainmail Trousers", "Dragon Skin Trousers", "Broken Stick", "Dagger", "Dragons Sword" };
int RarityOption[] = { 0, 1, 3, 0, 3, 0, 2, 3, 0, 2, 3, 1, 2, 3 };
bool SetOption[] = { 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 };



class Loot // grouping name rarity into set
{
public:
string Name;
int Rarity;
bool Set;

Loot(string N, int R, bool S) // constructor initialises each of the feilds
{
Name = N;
Rarity = R;
Set = S;

}

};

class TreasureChest
{
public:
stack<Loot> Chest;
// define default constructor
TreasureChest()
{
int i = rand() % LootNumber;
for (i = 0; i < 5; i++)
{
Chest.push(Loot(NameOption[i], RarityOption[i], SetOption[i]));
}

}
};


// This prints a random selected item of loot to the screen
void PrintLoot()
{
int i = rand() % LootNumber;
Loot A(NameOption[i], RarityOption[i], SetOption[i]);
cout << "Loot item: " << A.Name << endl;
cout << "Rarity out of 3: " << A.Rarity << endl;
cout << "Part of set: " << A.Set << endl;
}

//Gives player choise whether to keep or discard each loot item as it is revealed from the stack
void PlayerChoice()
{
char Answer;
cout << "If you want to keep the item press Y" << endl;
cout << "If you want to discard the item press N" << endl;
cin >> Answer;
while (Answer == 'Y' || Answer == 'y')
{
cout << "Item stored in your bag" << endl;

// store item in bag array using pointer
return;
}
while (Answer == 'N' || Answer == 'n')
{
cout << "Item was discared from the Treasure Chest" << endl;
return;
}
while (Answer != 'y' || Answer != 'Y' || Answer != 'N' || Answer != 'n')
{
cout << "To decide press Y for accept OR press N for Decline" << endl;
cin >> Answer;
if (Answer == 'Y' || Answer == 'y') {
cout << "Item stored in your bag" << endl;
//*Bag = TreasureChest().Chest.top;
return;
}
else (Answer == 'N' || Answer == 'n'); {
cout << "Item was discared from the Treasure Chest" << endl;
return;
}
return;
}
}


// function that prints the contents of TreasureChest to the screen whilst asking the player if they want each item.
void PrintTreasureChest()
{
TreasureChest A;
int j;
for (j = 1; j < 5; j++)
{
cout << "Item " << j << " in your chest is: " << endl;
cout << "Name:" << (A.Chest.top()).Name << " Rarity out of 3: " << (A.Chest.top()).Rarity << " Part of a set: " << (A.Chest.top()).Set << endl;
PlayerChoice();
A.Chest.pop();
}
cout << "The chest is now empty" << endl;
return;
}
1) Why didn't you use the "code" tags like you did in this post?
http://www.cplusplus.com/forum/beginner/213376/

2) There isn't main(), how are we supposed to compile your code?

3) string *Bag[6]
Are you sure you want an array of pointers to std::strings?

4)
a pointer array that will store the loot item from the top of the stack called chest
Are you sure you want to use a stack?
A 'bag' conveys the idea of something that store things that can be accessed in any order...

I think that if you improved your post you could find more help.
How would you recommend building something that stores things and can be accessed later?
I do apologies for my terrible everything really i am so new to this it literally blows my mind at times I dont seem to have the natural talent a lot of coders do.
Sorry, @Chronic Arrow,
haven't been around for a while.
I'm sure you have already found your solution, but just to put in my two pennies' worth: I'd use a std::vector.

Happy coding!
Topic archived. No new replies allowed.