typedef char STR10[10+1];
typedef char STR20[20+1];
typdef struct Slot
{
STR10 key;
STR10 value;
};
const int MAX_SLOTS = 3;
const int MAX_BUCKETS = 30;
typedef struct Bucket
{
short int count;
short int overflow;
Slot slots[MAX_SLOTS];
};
typedef Bucket HashTable[MAX_BUCKETS];
Mostly I’m just confused with the concept of the last line. I know I can just change the structs to classes and that would be good, but the last line is getting to me. It’s basically saying a HashTable is an array of buckets. Is that code good enough or is there a way to represent that in a HashTable class?
class HashTable
{
private:
Bucket table[MAX_BUCKETS];
}
would that represent the same idea? I’m really struggling with getting this started.
If I could, I may replace char array with std::string, Slot array with std::vector, replace define with enum: