Listing 26 A placement operator new with two arguments

// overload.cpp
#include <iostream.h>

void *operator new(size_t siz, void *arg1, int arg2)
{
    cout << "new: siz == " << siz
        << ", arg1 == " << (void *) arg1
        << ", arg2 == " << arg2 << endl;
    return arg1;
}

main()
{
    void *p = (void *) 0x1234;
    int *ip = new (p,100) int;
    cout << "ip == " << (void *) ip << endl;
    return 0;
}

/* Output:
new: siz == 2, arg1 == 0x1234, arg2 == 100
ip == 0x1234
*/
// End of File