独自の配置の新規および配置の削除 (追加のパラメーターを使用) を定義したいのですが、配置の削除にアクセスできませんでしたが、配置を正しく呼び出すことができました。プレースメントの削除を間違って定義したのか、それとも間違って呼び出したのか誰か教えてもらえますか?
class A
{
public:
A( int a ) : a(a){}
static void* operator new( std::size_t, int ); // the placement new
static void operator delete( void*, int )throw(); // the corresponding placement delete
private:
int a;
};
void* A::operator new( std::size_t size, int n )
{
std::cout << "size: " << size << " " << "n: " << n << std::endl;
return ::operator new(size);
}
void A::operator delete( void* p, int n )throw()
{
std::cout << "n: " << n << std::endl;
::operator delete(p);
}
int main( int argc, char* argv[] )
{
A* a = new(10) A(100);
std::cout << std::endl;
delete(4) a; // error???????????????????, but how?
return 0;
}