我有以下代码
#include <iostream>
#include <cstddef>
#include <string>
#include <memory>
class Object
{
public:
Object()
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
}
std::string x;
void *operator new( size_t bytes )
{
std::cout << __PRETTY_FUNCTION__ << " : bytes = " << bytes << std::endl;
}
void operator delete( void * arg )
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
}
};
int main( int c, char *v[] )
{
// std::auto_ptr< Object > pObject( new Object() );
Object *o = new Object();
delete o;
}
它产生这个输出。。。
static void* Object::operator new(size_t) : bytes = 8
然后是堆芯转储。
假设我没有从操作符delete()方法获得输出,并且它是核心转储。我假设我的运算符delete()方法没有被调用。
有人能解释为什么它没有被调用吗?
感谢你关注我的全帽咆哮的核心转储,因为事实证明这是个问题
EDIT-- Ok, Where do I start.... I m incredibly sorry for ranting. We ve all been there, under pressure to meet a deadline and something innocuous appears to be causing an issue and we re convinced it s one thing when in fact it s another. This has taught me a valuable lession... I need to start listening.... I fully appreciate all of help and advice given here.
Thx Mark.