Recommended Posts

Hi;
Im doing a simple memory manager, to avoid fragmentation, using a very large array of bytes and casting som portions to the struct i need. It works to structs and classes, but for inherited classes the vftable is not filled. How can i do that? is there som way to force the casting?

Share this post

Link to post

Share on other sites

Placement new calls the constructor of the class on the memory address that you specify. In the code snippet above, you grab the memory using your custom allocator then construct the class in that memory.

I''m not sure of any good online references to overriding operator new() and operator delete() for a class. However, IIRC, the book "Effective C++" by Scott Meyers has a few items on using operator new() and operator delete() in classes.