KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I know you can overload the operator new . When you do, you method gets sent a size_t parameter by default. However, is it possible to send the size_t parameter - as well as additional user-provided parameters, to the overloaded new operator method? For example int a = 5; Monkey* monk = new Monkey(a); Because I want to override new operator like this void* Monkey::operator new(size_t size, int a) { ... } Thanks EDIT: Here's what I a want to accomplish: I have a chunk of virtual memory allocated at the start of the app (a memory pool). All objects that inherit my base class will inherit its overloaded new operator. The reason I want to sometimes pass an argument in overloaded new is to tell my memory manager if I want to use the memory pool, or if I want to allocate it with malloc.
Tags (comma-separated)
Save Edits
Cancel