I'm working on a preparing some code for what will ultimately be a MUD; this is my first 'big' project and I am gradually chiseling out the errors; however, some problems are now hindering my project and I just can't seem to break them. Here is my code:
#include <iostream>
using namespace std;
int test_var;
#define K 125
#define TEST 50
struct item {
int quantity;
//Some More Stuff Will Be Inside Later//
};
struct inventory {
struct item[K]; //Error 1 - "expected unqualified-id before '[' token"
} test;
int main()
{
cout << "Number?" << endl;
cin >> test_var;
test.item[TEST].quantity = test_var; //Error 2 - "'struct inventory' has no member named 'item'"
cout << test.item[TEST].quantity << endl; //Error 3 - "'struct inventory' has no member named 'item'"
cout << test.item[TEST].quantity; //Error 4 - "'struct inventory' has no member named 'item'"
return 0;
}
I have to apologize as this code is a bit sloppy, but this represents two things tasks that I'm trying to accomplish. Number 1, I need some way of having an array of structure 'items' inside the structure 'inventory'. Number 2, I need to insure that I can access the individual elements inside the structures; the actual code involves a couple more structures inside structures and it is vital that I can access the individual, non-structure elements (ints, bools, doubles, strings). If anyone can offer many any advice on these issues, I would be grateful. Thank you