You would need to create a new vector for the first 2 dimensions so that the third one could have something to be placed in. I think another possible solution to this problem you have is have just 1 vector and a structure, and make some functions to find the correct structure. For example:
Item& findRecordByItemID(std::vector<Item> &list, int id)
{
int length = list.size();
for (int i = 0; i < length; ++i)
{
if (list[i].itemID == id)
{
return list[i];
}
}
}
Then after inserting this stuff into item list you could do something like:
I've done quite some research, and I think set will be better than vector. But there is one problem that I don't know. If I have the struct as you suggest, then what member will set use to sort?
And why would I prefer set more than vector, because the amount of data is a lot. Then binary search would be a better search algorithm than sequential search, right? But then again, sometimes I need to search for the itemID first to find others stuff, sometimes I need to find the userID before all. I know what I want, and I know that a sorted array is easier to search, but I couldn't think of a way to sort it properly.