I have a large, expanded class that is essentially a very friendly two-dimensional linked list. I want to be able to "compile" it, by which I mean that I want to finalize the list so that only read access can be made, and then move all the elements in the nearest memory space. My uncomfortable solution is:
#include & lt; New & gt; ... MyListNode * pool = New MyListNode [Length]; New (and pool [status]) MyListNode (); The problem is that I have essentially two classes, which are allocated together with one and the other have been allocated with this method, and when I have been allocated in the above allocated items Efforts to remove anybody from, Glibc kills the program because of an invalid indicator.
The natural solution is to create two squares, and use Runtime polymorphism to provide only one interface, but two implementations, etc. Is there any way that such a Gigre Pokiri permits the memory stand in C ++?
Are you calling delete on an object from your array ? Or are you applying a destructor manually to mirror the appointment manually?
Since you have a non-placement new call, you only have to delete one call and since you have annex to the placement-nu, you should manually try the Destructor N Bar needed.
Therefore, you want something like this:
// All instead of an array of MyListNode, an array of characters, because we are going to use // new placement If MyListNode has a // default default constructor, MyListNode * pool = static_cast & lt; MyListNode * & gt; (New char [sizeof (MyListNode) * length); (Size_t position = 0; position & lt; height; ++ position) for new (and pool [status]) MyListNode (); ... for (condition = 0; condition & lt; length; ++ position) pool [position]. Delete MyListNode () [] static_cast & lt; Char * & gt; (Pool);
Comments
Post a Comment