Adapter and Adaptee Classes

  adapter, c++, oop

I have an assignment where I am to create a class called HashTable that is to eventually store pairs of usernames and passwords and then another class called PassServer. The h file I am showing below are given and can be added to but not removed. To keep save space, here is what is pertinent to this question from HashTable:

template <typename K, typename V>
    class HashTable {
       std::vector<std::list<std::pair<K, V>>> hashTable;

As for PassServer, we are only given a list of public and private functions we need to implement, no pre-defined h file. The only private data member required of PassServer is string encrypt(const string & str);.

Now, in the assignment it says:

"PassServer should be implemented as an adaptor class, with the HashTable
you developed as the adaptee class. The type for both K and V in HashTable
should be string. The key and value will be the username and password,

I have never heard of an adapter and adaptee class until today so I am not sure what is the correct or best way to implement it. I have 3 different routes I am thinking.

  1. I define PassServer to inherit HashTable: class PassServer: public HashTable<string, string>
  2. class PassServer: private HashTable<string, string>
  3. I don’t inherit HashTable at all and instead add a private data member to PassServer like: HashTable<string, string> passServer;

I hope I provided enough information. This is an assignment so I don’t want to post it all on here. I really just need to know about this because I don’t know which is best(or right) and my professor can take a very long time to respond to questions and I am working on it now.


Source: Windows Questions C++