Oops, I didn't meant that?
I meant the data pointed by that pointer.
Sorry,
I will just edit it

[edit]
I replied too quickly.
Bjarne states that standards doesn't stops the implementors to reset the pointer just deleted to NULL

Oops, I didn't meant that?

Thought so :D

I replied too quickly.
Bjarne states that standards doesn't stops the implementors to reset the pointer just deleted to NULL

C++ explicitly allows an implementation of delete to zero out an lvalue operand, and I had hoped that implementations would do that, but that idea doesn't seem to have become popular with implementers.

>that politeness will cost you a 14 hour bug in your program.
You make it sound as if being polite makes you a crap programmer all of a sudden.

On your first post, you could have accomplished the same without giving everybody a bad impression of you.
I think it would have gone something like this:

>>Why didn't the C++ standard also have the delete operator reset ptr to NULL?
C++ standards have been made by the most proficient and experienced programmers of this language. If you think there should be a feature added doesn't means it should be added. A boon to you may be disaster to others. C++ standards have to keeps everyone in mind.

But then there's a problem, just check what would happened if delete reseted the pointer to zero:

int * p=new int;
int *q=p;// q points to same memory as p
delete p; //deleting p and setting it to zero
delete q;// Oops! deleting pointer to null 0

So try to think how costly (or perhaps dangerous) that could be. Even if you can't think how costly it is, just trust the proficient and experienced programmers of this language.

Just by removing a few lines and copying a couple of phrases, it's a much nicer tone and less people are annoyed. :icon_rolleyes:

Got that!!?

>>You make it sound as if being polite makes you a crap programmer all of a sudden.
Not at all. I am just want to point out that believing everyone who is polite, will eventually lead to beak down. (I never ever meant that it will bring out a crap programmer. My point is : politeness is got nothing to do with your programming expertise.)

>>On your first post, you could have accomplished the same without giving everybody a bad impression of you.
I think it would have gone something like this:

Oh please Hemsworth, give me some C++ knowledge if you have. I don't sit here on dani for moral education.

PS: Go and check out my posts on the other threads. you won't see 'this' me in those posts. If I was rude in this thread, it was for a reason. Only if you all guys would be more of programmers rather than 'customer care executives'

sidiot> You won't see 'this' me in [other] posts
sidiot> If I was rude in this thread, it was for a reason.

This is simply a lie. There was absolutely no "reason" to be rude. Not only was the sidiot rude, he was also wrong!

He doesn't bother to properly read and understand other people's posts. He assumes everyone is stupid. "Who are you to question me?" he says (and he says this to me when I'm correcting his obvious error). This bespeaks a deep psychological problem, one we are not about to solve here.

The fact is that the sidiot is total jerk. If he's going to continue lying we can keep this thread on the front page for a month; then everyone can see what a jerk he is.

(He'll probably even respond to this post. What a sidiot!)

commented: Don't provoke him :angry: !! +0

Enough of the personal insults. The next one will get a nasty infraction.

Promise me that you/ your students will not ask questions like these in forums like these.

You should be ashamed of yourself, and your attitude disgusts me.

For the beginners of C++, The standards should be treated as Laws. For experienced programmers, these things will eventually clear up as you learn more and gain experience.

Of course your previous demand will preclude the beginners from learning anything by crushing their inquisitive spirit. They won't reach the point where everything clears up and will either leave the field or become one of those bad programmers we all fear will join our team.

It seems we have opposite philosophies on learning. I believe that all questions should be answered completely. If a student has reached the point where he knows enough to ask the question, he knows enough to be given an honest answer rather than tripe about how he's too inexperienced to "get it".

To the Ancient Dragon:
I wrote in post #33:
>>I replied too quickly.
Bjarne states that standards doesn't stops the implementors to reset the pointer just deleted to NULL

Do you agree?
Or am I in some wrong misconception?
I researched and found that it is true that C++ standards doesn't stop compiler writer to reset the deleted pointer to null.
http://www.research.att.com/~bs/bs_faq2.html#delete-zero

Of course your previous demand will preclude the beginners from learning anything by crushing their inquisitive spirit. They won't reach the point where everything clears up and will either leave the field or become one of those bad programmers we all fear will join our team.

It seems we have opposite philosophies on learning. I believe that all questions should be answered completely. If a student has reached the point where he knows enough to ask the question, he knows enough to be given an honest answer rather than tripe about how he's too inexperienced to "get it".

Good.
Narue, I think it was me the first who tried to satisfy OP by giving at least a logical explanation (rather than that 'giving more control to the programmer' logic) [It doesn't prove anything]
But what annoyed me really was the reply of Nucleon. Seriously, that took my nerves apart.
Your philosophy may be right. But can you (or anyone here around) seriosly answer that question? I could just get OP close to real thing because I just told him what was on Stroustrup's Homepage.
As Ancient said, only a member of ISO committee ( of perhaps some of their close friends) can really answer that.

PS: How can we discuss these things without spoiling the thread? I really feel very sorry when we discuss ( or fight) here. On the other hand, these discussions are important too.
PPS: Of topic- How do I pronounce your name? :)

>Bjarne states that standards doesn't stops the
>implementors to reset the pointer just deleted to NULL
The standard doesn't stop them, common sense does. Adding an extra operation (assigning null to the pointer being deleted) introduces all kinds of problems. Here are a few:

  • C++'s philosophy is broken. You're paying for something 100% of the time that you only use 10% of the time (being very generous).
  • It doesn't solve the problem at all. Consider pointer aliases. If you have two pointers pointing to the memory, deleting one of them only sets that pointer to null. The other pointer still refers to freed memory.
  • It doesn't apply to all cases. For example, what if the pointer is const?

Automatically setting the pointer to null adds complexity and buys nothing, taking into account that this task is trivial without adding compiler behavior, and the programmer is in a better position to use it judiciously.

>But what annoyed me really was the reply of Nucleon. Seriously, that took my nerves apart.
It looks to me like nucleon replied to you in the same tone that you replied to the OP.

>But can you (or anyone here around) seriosly answer that question?
Yes, as a matter of fact I could have answered all but one of the questions asked by the OP. The only question I can't answer conclusively (because I wasn't there) is the question about whether this feature was talked about in the committee. I can almost guarantee that it was though, as no feature goes into the language without a good bit of discussion.

>PS: How can we discuss these things without spoiling the thread?
Not possible. Programmers are especially proud people, so technical discussions can get messy quickly. If you want to improve matters by remaining on-topic, I'd suggest restraining yourself when somebody calls you on your rudeness. Nothing "spoils" a thread faster than some boy scout coming along trying to get everyone to play nice and his target retaliating.

In other words, if you don't like the consequences of your attitude, change your attitude.

>PPS: Of topic- How do I pronounce your name?
NAH-roo-way, approximately.

commented: Very well said. +9

Good post Narue.

And slightly off topic again, but I noticed this today for the first time on the link Narue gave :)

The Japanese have trouble to pronounce and tell the difference between the English "r" and "l' because these sounds don't exist in Japanese.

My japanese teacher was struggling to pronounce 'umbrella' throughout most of the topic, I found it ammusing how she kept saying 'umbrerara' :D

>>The standard doesn't stop them, common sense.................................
...........position to use it judiciously.
Right and Done.
>>it looks to me like nucleon replied to you in the same tone that you replied to the
I don't think so. I never abused the OP. Moreover, Nucleon responded utter non-sense. His motto was to degrade my remarks. While, motto was to inform OP, Not to ask question like these ( Now,I don't want comments regarding whether or not it is the right Philosophy, we already had a discussion regarding). Also, his posting added to anyone's knowledge about C++.

>>The only question I can't answer conclusively .................of discussion.
Agree.

>>Not possible. Programmers are especially proud people, .....................
Good to hear that.

>>NAH-roo-way, approximately.
Oh man! this can't get so crazy of me. I was here sitting in front of my PC with everyone around in my room. I followed the link and tried to pronounce your name. After trying about 15-20 times repetitvely, I noticed that everyone was looking at me with their Big eyes. And then my dad asked " What's the matter son, is everything ok?" and I said "Of course dad".
I although is still not perfect to pronounce your name, but I think I am close to it.
If you ever had time, try to post a MP3 file of your pronunciation.

Hemsworth>>Good post Narue.
Yeah , It really was a good one.

So when are we planning to close this thread?

sid> But what annoyed me really was the reply of Nucleon.

Sorry if I made you cry, sid, but if my post imitating your style annoyed you, imagine how your original post felt to the OP. Are you getting it now? Do you see the point?

narue> boyscout

Actually, since I don't believe in invisible people (hence the "atheist atom" symbol), I can't be a boyscout! (BTW, my opinion of Narue is very high. I think she's great. And, as you'll see, I'm not just sucking up.)

AD> Enough of the personal insults. The next one will get a nasty infraction.

That is absolutely ridiculous! Moderators' time is better spent telling people not to tell lies. And what about sid's original personal insults to the OP? Of course, that's okay! No reprimands for sid! He's just the greatest! Why don't you give him yet more rep? Obviously he's the kind of person that Daniweb wants!

To all:

In my opinion, someone who helps others should have three qualities:
1. Know the subject (and their own limitations).
2. Explain things clearly (and carefully read what others say).
3. Be nice. (Why not?)

Number 1 is straightforward. Programming is not an arcane art but an engineering discipline. A major design criterion in any programming language is ease and practicality of use. Knowing how to program doesn't make you a genius, no matter what your mommy says. ("Oh siddy, my little genius!")

Number 2 is somehow not so easy. Perhaps it's because human languages are not designed but evolve, which make them infinitely more difficult than programming languages.

Number 3 would SEEM to be easy, but for some reason is the rarest of all. It doesn't matter what site you go to, people are jerks. This teaches others to be jerks, perpetuating the jerkiness. I thought Daniweb could be different. I was wrong.


Goodbye, cruel Daniweb! (for good this time)

commented: Cya +9
// B.Stroustrup's 'good' deallocator from
// http://www.research.att.com/~bs/bs_faq2.html#delete-zero
template<class T> inline void destroy(T*& p) 
{ 
    delete p; p = 0; 
}
void nulllover()
{
    struct U { U* p; };
    U* p = new U;
    p->p = p; // why not? p->p is l-value...
    destroy(p->p); // 100% legal way to nowhere
    // the same 'effect' with null setter operator delete
}

>No reprimands for sid! He's just the greatest! Why don't you give
>him yet more rep? Obviously he's the kind of person that Daniweb wants!
I believe AD was referring to everyone. But I will add that those most offended by a general reprimand are often those with a guilty conscience. ;)

>1. Know the subject (and their own limitations).
I try to.

>2. Explain things clearly (and carefully read what others say).
I try my best.

>3. Be nice. (Why not?)
I'm not nice. At all. And I have my reasons, though the people who try to emulate me don't get it, and the boy scouts don't want to. If your opinion of me is very high, how is it you tolerate me only having two of your three qualities?

>Goodbye, cruel Daniweb! (for good this time)
I've seen that threat many many times, and I've only seen it carried out successfully once.

commented: That's right, siddhant3s is great !! +3

>>Sorry if I made you cry, sid, but if my post imitating your style annoyed you, imagine how your original post felt to the OP. Are you getting it now? Do you see the point?
Sorry, Nucleon. Your mission was not accomplished. You didn't made me cry but just worst. You made me angry at you. I have already pointed the differences between my posts and yours. So don't compare both the posts.

>>I don't believe in invisible people (hence the "atheist atom" symbol)
:) Thats good. BTW, as I remember my physics, you cannot see the atoms from your eyes.

>>That is absolutely ridiculous! Moderators' time is better spent telling people not to tell lies. And what about sid's original personal insults to the OP? Of course, that's okay! No reprimands for sid! He's just the greatest! Why don't you give him yet more rep? Obviously he's the kind of person that Daniweb wants!

>>That is absolutely ridiculous! Moderators' time is better spent telling people not to tell lies.
Maybe it is ridiculous to you, but I think Ancient was being himself rather than being a moderator in this thread.

>>And what about sid's original personal insults to the OP? Of course, that's
>>okay!
You are again comparing the two posts which are different.

>>No reprimands for sid! He's just the greatest!
Are your reprimands any less?

>>Why don't you give him yet more rep? Obviously he's the kind of person that
>>Daniweb wants!
Thats none of your business.


>>Programming is not an arcane art but an engineering discipline.
Yes it is. But it is no less than an arcane.

>>A major design criterion in any programming language is ease and practicality of use.
Tell this to stroustrup or any other language designer. We are none of them.
(Anyways, it was nice to know. (as if we never knew) )
>>Knowing how to program doesn't make you a genius, no matter what your mommy says
:-/

>>Goodbye, cruel Daniweb! (for good this time)
This means that you are saying good-bye to this thread, right?
Not what Narue interpreted. ( If it is, let me tell you that I don't want you leave dani)


Narue>>If your opinion of me is very high, how is it you tolerate me only having two of your three qualities?
How do you every time prove others wrong.:D


ArkM>>
// why not? p->p is l-value...
Yes it is.
#
// 100% legal way to nowhere
// the same 'effect' with null setter operator delete
I don't think the effect is undesirable? Do you?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.