Page 1 of 1

Stupid C question.

PostPosted: Apr 23, 2004 @ 1:55pm
by kornalius

PostPosted: Apr 23, 2004 @ 2:12pm
by Dan East

PostPosted: Apr 23, 2004 @ 4:13pm
by kornalius

PostPosted: Apr 23, 2004 @ 6:19pm
by Tala

PostPosted: Apr 23, 2004 @ 7:55pm
by kornalius
ok thanks.

Regards,
Kornalius

PostPosted: Apr 26, 2004 @ 1:16am
by fdave

PostPosted: Apr 26, 2004 @ 12:40pm
by Dan East
It would be:

DOUBLE d;
DOUBLE &d2=d; //not =&d;

I guess that would work, but it is a terrible programming practice. I can just imagine the convoluted mess that would result, since it would not be clear which vars are "real" and which are references. The advantage of a pointer is that it really is a different type.

This is on a completely different note, but I feel it is bad practice to declare like this:
DOUBLE& d2;
instead of this:
DOUBLE &d2;

We discussed this a couple years ago. The former gives the appearance that you are using the type DOUBLE&, when the ampersand is really a modifier for a single variable.

Here's where that syntax is problematic:
DOUBLE& d1, d2;

That gives the appearance that both d1 and d2 are "DOUBLE &", whereas only the d1 is a reference, not d2.

DOUBLE &d1, d2;

That makes it perfectly clear what is being declared.

Dan East

PostPosted: Apr 27, 2004 @ 1:07am
by j.edwards

PostPosted: Apr 27, 2004 @ 1:14am
by Kzinti

PostPosted: Apr 27, 2004 @ 2:33am
by j.edwards

PostPosted: Apr 27, 2004 @ 2:37am
by Dan East

PostPosted: Apr 27, 2004 @ 2:54am
by Kzinti

PostPosted: Apr 27, 2004 @ 4:05am
by StephC