Invoke a new one with this additional operand, for example
Monkey *amonkey = new (1275) Monkey(a);
additions
A practical example of passing the argument [s] to your new operator is given the Boehm garbage collector , which allows you to encode
Monkey *acollectedmonkey = new(UseGc) Monkey(a);
and you donβt need to worry about delete -ing acollectedmonkey (assuming its destructor doesnβt do strange things, see this answer ), These are rare situations when you want to pass an explicit Allocator argument to a template collection, for example std::vector or std::map .
When using memory pools, it is often required to have a MemoryPool class and pass instances (or pointers to them) of this class to your new and your delete operations . For reasons of readability, I do not recommend referring to memory pools by any obscure integer.
Basile starynkevitch
source share