Suppose I have a linked list that I created myself. It has its own destructor, which frees memory. This Linked List does not overload new ones or delete.
Now I'm trying to create an array of the specified linked lists (open hashing, if I understand correctly). Then I allocate the necessary memory inside the constructor of this public hash class. The new statement called inside the constructor is enough to allocate memory for the array correctly, right? I'm not sure, because I did not overload the new ones for the Linked List class.
Also, if my array of linked lists is called elements, can I just write "delete [] elements" in the destructor? Could this cause a destructor for each element in the array and free memory properly?
Finally, if both of my assumptions are correct (i.e. I donβt need to overload new ones and delete them to use them with my custom class), what is the point of overloading such operators?
c ++ constructor new-operator destructor
hadou shoryu Dec 25 '08 at 2:46 2008-12-25 02:46
source share