I'm practicing various C++ exercises. In this particular exercise they are asking me to implement an in memory database. I guess they are not asking me to use something like SQLlite. Could anybody give some general pointers as to how I should tackle this please? Would I use C++ maps. I'm struggling to understand what they mean by in memory?
closed as too broad by TheCatWhisperer, amon, Doc Brown, gnat, Christophe Feb 28 '18 at 19:21
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
I assume you're allowed (expected) to use the STL (or whatever it's called these days -- the "standard library", probably).
To "store items of distinct types", use some template container(s).
To support "item belongs to one category", store item+category pairs (which is more-or-less how a database would do it), or sets of items for each category (possibly a single map with category as key and set of items as values).
It says "distinct" types so perhaps you can't assume the types are related at all.
"In memory" means it doesn't need to be serialized or saved to disk ... and presumably mustn't use an existing database implementation which isn't part of the C++ standard library.
It's not clear to me what the "identity" of an item is. E.g. does every type have an ID? Or do you pass the address of (i.e. a pointer to) an item as a parameter to the remove method?