By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,332 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,332 IT Pros & Developers. It's quick & easy.

Is it a question?!

P: n/a
I don't decide it, and I need help.

Q:
const int* pInt = new int(0);
delete pInt;
Jul 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
On 6 Nov 2003 03:14:10 -0800, xh******@sina.com.cn (xhzeng) wrote:
I don't decide it, and I need help.

Q:
const int* pInt = new int(0);
delete pInt;

A:
c:\Dev\test\dotnettest\dotnettest\dotnettest.cpp(2 ) : error C2059:
syntax error : 'delete'

Tom
Jul 19 '05 #2

P: n/a
xhzeng wrote:
I don't decide it, and I need help.
You don't decide what?
Q:
const int* pInt = new int(0);
delete pInt;


This is a piece of code. Not a valid C++ program, but might be valid as
part of one.
But what is the question?

Jul 19 '05 #3

P: n/a

"xhzeng" <xh******@sina.com.cn> wrote in message
news:c2*************************@posting.google.co m...
I don't decide it, and I need help.

Q:
const int* pInt = new int(0);
delete pInt;

No, it is not. It is not a question. Even
const int* const i = new int(0);
delete i;
is not a question because destructors are allowed to run for const objects
too.

--
Michael Kochetkov.
Jul 19 '05 #4

P: n/a
xhzeng wrote:
I don't decide it, and I need help.

Q:
const int* pInt = new int(0);
delete pInt;


It is just a fragment of valid C++ code. Now, what is the question and
what is it that you "don't decide"?

--
Best regards,
Andrey Tarasevich

Jul 19 '05 #5

P: n/a
xhzeng wrote:
I don't decide it, and I need help.

Q:
const int* pInt = new int(0);
delete pInt;


You ran this trough an Internet translator, something like Altavista
Babelfish, I suspect? Unfortunately, none of us can really make out what the
question you have is. Perhaps you would be better of finding help on a forum
where they speak your language.

--
Unforgiven

"You can't rightfully be a scientist if you mind people thinking
you're a fool."
Jul 19 '05 #6

P: n/a
If this is an answer =)
Jul 19 '05 #7

P: n/a
xhzeng wrote:
I don't decide it, and I need help.

Q:
const int* pInt = new int(0);
delete pInt;


Drop the "const". You can't delete a const pointer.

Jul 19 '05 #8

P: n/a


Calum wrote:

xhzeng wrote:
I don't decide it, and I need help.

Q:
const int* pInt = new int(0);
delete pInt;


Drop the "const". You can't delete a const pointer.


Says who?

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 19 '05 #9

P: n/a
Karl Heinz Buchegger wrote:
Calum wrote:

xhzeng wrote:
> I don't decide it, and I need help.
>
> Q:
> const int* pInt = new int(0);
> delete pInt;


Drop the "const". You can't delete a const pointer.


Says who?


Says "Calum" :-)

And just to make that posting at least a bit useful: pInt is not a const
pointer, but a pointer to const.

Jul 19 '05 #10

P: n/a
> > > I don't decide it, and I need help.

Q:
const int* pInt = new int(0);
delete pInt;


Drop the "const". You can't delete a const pointer.


Says who?


IIRC MSVC 6 doesn't allow deleting const pointers, even though according
to the standard it should.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl

Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.