can we debug into delete

G

George2

Hello everyone,


I am using Visual Studio 2005 and I am wondering whether we could
debug into the global delete operator?

I have tried to debug by setting a break point to delete statement,
but I could only debug into destructor.

My understanding is, when we call delete, the internal operations are,

1. invoking destructor;
2. invoking global delete operator.

Is my understanding correct?

For example,

Code:
class Foo {

int i;

public:

	Foo()
	{
		i = 100;
	}

	~Foo()
	{
		i = 0;
	}
};

int main (int argc, char** argv)
{
	Foo* f = new Foo();

	delete f;  // can not debug inside

	return 0;
}


thanks in advance,
George
 
S

Stuart Redmann

George2 said:
Hello everyone,

I am using Visual Studio 2005 and I am wondering whether we could
debug into the global delete operator?

Debugging is in general OT in this newsgroup. Debugging under a particalur
platform is even more OT.
I have tried to debug by setting a break point to delete statement,
but I could only debug into destructor.

My understanding is, when we call delete, the internal operations are,

1. invoking destructor;
2. invoking global delete operator.

Is my understanding correct?

Almost. If a class has an overwritten delete operator, this particalur
implementation is called (I almost surely used the terms 'operator delete' and
'delete operator' incorrectly here. There is a difference between these terms
that some follow-ups to this posting will explain, but most people can live with
using the terms incorrectly :)
For example,

Code:
class Foo {

int i;

public:

	Foo()
	{
		i = 100;
	}

	~Foo()
	{
		i = 0;
	}
};

int main (int argc, char** argv)
{
	Foo* f = new Foo();

	delete f;  // can not debug inside

	return 0;
}

Regards,
Stuart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,196
Messages
2,571,036
Members
47,631
Latest member
kukuh

Latest Threads

Top