Alf P. Steinbach wrote:
* tom:
why delete the dynamically allocated memory twice causes an error,
see the code below:
int _tmain(int argc, _TCHAR* argv[])
{
int *pi = new int(12);
cout<<*pi;
delete pi;
delete pi;
}
There's no such thing as _tmain in standard C++. There's no such
thing as _TCHAR in standard C++. Your code does not compile. This
group is for discussing standard C++. Please fix your example, and
repost.
Chill, Alf. For all we know, _tmain is a function OP wrote himself.
And what _TCHAR is *is* quite irrelevant to the question asked. Of
course "_TCHAR" is a reserved identifier which makes it prohibited
in the program outside of the library implementation. And 'cout' is
not really defined here. But, hey, so what? To ask a question like
that the code doesn't even have to be complete. It should be enough
to write
int *pi = new int(12);
// use pi somehow
delete pi;
delete pi;
to get a normal answer to the question. Perhaps you should get off
your high moderator's horse once in a while, eh?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask- Hide quoted text -
- Show quoted text -
I'm new here. And that's why I need to make a post here and ask
questions.
of the variable. And
be a compiler 100% follow the standard.