J
JKop
Why the hell did they make "this" a pointer and not a reference?!! It's so
stupid!
-JKop
stupid!
-JKop
JKop said:Why the hell did they make "this" a pointer and not a reference?!!
It's so stupid!
-JKop
Why did they make "this" a pointer and not a reference?
the hell!! It's so stupid!
Pete said:Perhaps references were not added to the language when the this pointer
was - I assume `this' was added in the first version.
Besides, it's easy enough to use *this.
- Pete
Why the hell did they make "this" a pointer and not a reference?!! It's so
stupid!
JKop said:Why the hell did they make "this" a pointer and not a reference?!! It's so
stupid!
JKop said:Why the hell did they make "this" a pointer and not a reference?!! It's so
stupid!
-JKop
button->Click+=new EventHandler(this, &form::OkButton_clicked);
Had this been a reference, passing "&this" above instead of "this",
would be tedious and in the event handling mechanism used in the
platform pointers to objects get passed (for example I could pass a
pointer of another object type).
So I guess everything depends on context. Your "clever" approach, would
be "stupid" in my platform.
JKop said:Ioannis Vranos posted:
Let's just say it's a matter of opinion!
Here's how I look at it:
Use pointers when there's arrays involved, eg. a strlen function.
Use pointers when you've to re-seat the pointer for any reason.
Use references everywhere else!
JKop said:Why the hell did they make "this" a pointer and not a reference?!! It's so
stupid!
-JKop
Ioannis said:void OkButton_clicked(Object *pSender, EventArgs *Args)
Roman Ziak said:... one can achieve the same results with both. Just different operators.
Do you prefer '->' before '.' ? Because you will type one character less ?
Can somebody explain to me why reference is considered to be _better_ than
pointer ? Is that because one can overload operator '.' and not '->' ? Or
something else ?
Phlip said:Why are these pointers? At a method interface, the only reason to
pass a pointer is it might be NULL.
Both those objects must truly exist. Prefer references unless you
need a pointer's extra abilities.
Phlip said:Ioannis Vranos wrote:
Why are these pointers? At a method interface, the only reason to pass a
pointer is it might be NULL.
JKop said:Why the hell did they make "this" a pointer and not a reference?!! It's so
stupid!
-JKop
Cy said:I've got an idea: why don't you learn the language as it is? What's stupid
is passing judgment on things beyond your control.
I've got an idea: why don't you learn the language as it is? What's
stupid is passing judgment on things beyond your control.
From my perspective, passing judgement on things that are allegedly beyond
my control is not at all stupid, it's fun, I enjoy it. Is bungee jumping
stupid?
Well, from that prospective, it is better for _this_ to be reference
for the consistency sake as it has all attributes of reference
(although I am not sure about NULL, why one cannot assign NULL to
_this_ ?)
However, I would still like to hear a reason about references vs.
pointers. It apears to me that references are limited versions of
pointers.
Does that question need an answer?
john
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.