Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 24th, 2006, 4:27 AM   #1
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
The Endless Pointer Declaration War

type* foo;
or
type *foo
or
type * foo
Which do you prefer?
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials.
--WilliamSChips on Slashdot
uman is offline   Reply With Quote
Old Jun 24th, 2006, 4:52 AM   #2
bivhitscar
Hobbyist Programmer
 
bivhitscar's Avatar
 
Join Date: Oct 2005
Location: Melbourne, Australia
Posts: 126
Rep Power: 4 bivhitscar is on a distinguished road
type * foo

Though, if I am declaring more than one, it usually goes like so: type * foo, *bar, *sna;
__________________
it's ironic considerate rarity patron of love higher knowledge engulfs me...
bivhitscar is offline   Reply With Quote
Old Jun 24th, 2006, 5:05 AM   #3
v0id
Hobbyist Programmer
 
Join Date: Apr 2006
Posts: 155
Rep Power: 3 v0id is on a distinguished road
I usually use
type *foo;
I don't really know why.
v0id is offline   Reply With Quote
Old Jun 24th, 2006, 6:10 AM   #4
free-zombie
Programmer
 
free-zombie's Avatar
 
Join Date: May 2006
Location: Bavaria, Germany
Posts: 50
Rep Power: 0 free-zombie is an unknown quantity at this point
Send a message via ICQ to free-zombie Send a message via MSN to free-zombie Send a message via Yahoo to free-zombie
type *foo;
has tradition in C; I use
type* foo
as I want to declare foo of type pointer-to-type - the * logically belongs to the type.
free-zombie is offline   Reply With Quote
Old Jun 24th, 2006, 6:59 AM   #5
Eoin
Hobbyist Programmer
 
Eoin's Avatar
 
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3 Eoin is on a distinguished road
type* foo
For me.
__________________
Visit my website BinaryNotions.
Eoin is offline   Reply With Quote
Old Jun 24th, 2006, 7:23 AM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Since I predate C++, I tend to use "int *whatsis"; however, I tend to use "int& whatsis." Quite frankly, anyone who would go to war over the issue should get a life.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 24th, 2006, 8:05 AM   #7
InfoGeek
Professional Programmer
 
InfoGeek's Avatar
 
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4 InfoGeek is on a distinguished road
I've been using type *var; till now. But I'm thinking of switching to type* var as a lot of experts tend to like it.
__________________
PFO - My daily dose of technology.
InfoGeek is offline   Reply With Quote
Old Jun 24th, 2006, 8:50 AM   #8
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
I tend to use type* for the same reasons as free-zombie. However, IIRC:
int a, *b;
Is shorthand for:
int a;
int* b
So I understand why some people use *var instead.
Arevos is offline   Reply With Quote
Old Jun 24th, 2006, 8:51 AM   #9
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
I wasn't aware there was a war about this. Whoever argues such a silly point really does need to get a life. Oh, and my preference matches Dawei. I use "int *p" and "int& r".
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Jun 24th, 2006, 9:54 AM   #10
Soulstorm
Hobbyist Programmer
 
Soulstorm's Avatar
 
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 243
Rep Power: 3 Soulstorm is on a distinguished road
'War'? Never heard of such a thing in pointers or pointer declarations...

I prefer 'int *p' and 'int &r'.

In my head, for some reason 'int * p' causes problems. In ObjC though, I sometimes use 'NSString* str', but that happens in very specific and few places.

I think that this is a matter of preference and only that. The topic of this thread is really exaggerating...
__________________
Project::Soulstorm (personal homepage)
Soulstorm is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC