tags:

views:

170

answers:

3
+12  A: 

The this concept was introduced before the reference concept was. At the time, this had to be a pointer.Source

GMan
A: 

As crazy as it sounds it is actually legal to delete this;. Sometimes it is even warranted, but very rarely.

Dima
That doesn't explain why it's a pointer. (Unless you're implying the rationale was that `delete this` needs to be legal.)
GMan
zneak
@GMan: You are obviously right, this is not the rationale. But I believe this is relevant to the question nonetheless.
Dima
@zneak: that would be even more weird than `delete this`. :)
Dima
It's relevant in that both the question and answer talk about `this`. But that's about it, I don't see how it has anything to do with the content of the question. :S
GMan
It is relevant, because the next logical question is "What does `this` being a pointer allow me to do?"
Dima
@Dima: Uh, not really. Then every answer is relevant to any question via some chain of "but then you could ask". You gives answers to asked questions, not answers to unasked/secondary/guessed/imaginary questions. Read it out loud: "Why is `this` a pointer? You can `delete this`!" So? Doesn't answer the question.
GMan
@GMan: Please see the answer by Richard Corden to the original question (http://stackoverflow.com/questions/645994/why-this-is-a-pointer-and-not-a-reference). Apparently, I am not the only one who thinks this is a relevant point.
Dima
@Dima: Pointing out someone has done the same thing is not, in any way, a rebuttal to an argument. A million people saying X doesn't make X correct, so especially one person doesn't.
GMan
We are not talking about correctness here, since everything I said in my answer is true. We are talking about the relevance to the question, which is inherently a vague notion and is a matter of opinion. I believe it is perfectly reasonable and useful to go a little beyond the question. For example, when the question is about dynamically allocated arrays, do you agree that it is perfectly reasonable to suggest to use std::vector instead?
Dima
@Dima: Correct as in the answer to "is this a valid answer to post", not the content. I never said anything that gave you reason to draw the conclusion that by correct I meant the content of the answer is factual. You implicitly said "it is correct for me to post this answer, because this person did it", and I pointed out that's a fallacy (ad populum, two wrongs don't make a right, sheer irrelevance); in context, correct in this case should pretty clearly mean "relevant". In any case, you can't go beyond a question if you never answered it in the first place.
GMan
You're right, I should have added to point about `delete this` to your answer. ;)
Dima
+1  A: 

From Stroustrup's FAQ

http://www2.research.att.com/~bs/bs_faq2.html#this

Steve Townsend