Class implementation of hashmap

I’m little bit confused why we are using destructor can you plz explain the role of destructor and how it’s going to work

@Ashu1318, since we are allocating memory dynamically in our hashtable implementation , we would need to deallocate those memory ourself , since in static memory allocation the deallocation is managed by system itself, but in dynamic allocation we have to do it, for that we have destructor, destructor is counter part of constructor, as constructor is constructed when object is initialized , the destructor is called when the class object goes out of scope such as when the function ends, the program ends, a delete variable is called etc. … So , destructor is the place where we handle the deletion of all the dynamic memory we allocated to our program, so that that memory can be used by some other program in execution

sir is it important to implement hashtable using class or can i skip it ??

its important as you will need to create several instances of hash table in application so class can give you flexibility and encapsulate all the data and function you will need.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.