Old 07-18-2006, 11:52 PM   #1 (permalink)
Dante’s Inferno
 
naruto1327's Avatar
 
Join Date: May 2006
Location: OLD PROFILE. NEW: NOODLEPOWA
Posts: 608
Reputation: 10
Send a message via AIM to naruto1327 Send a message via MSN to naruto1327 Send a message via Yahoo to naruto1327
Default Your C++ Coding Preferences

I would like to know some of your C++ Coding Preferences.
With:

- Indentation
-- Four Spaces
- Bracket placement
Code:
void shout()
{
    cout << "HELLO!!!!!!!";
}
- Spaces between operators and declarations
-- Yes: n + m; Yes: int n = 1;
- Spaces between function name and starting parenthesis
-- None: shout();
- Spaces between loop name and starting parenthesis
-- One: if (n == 0)
- Where the * goes in declaring a pointer (next to the type name or the variable name)
-- Not sure for now, thats why I'm asking for your preferences but for now it's: int * n;
- Where the & goes in declaring a reference (next to the type name or the variable name)
-- Same as pointers: int & m = n;
- Whether you omit the <int> in the following specialization:
(
Code:
template <> void swap<int>(int &, int &)
)
-- Yes

Responses would be very helpful.

Last edited by naruto1327; 07-18-2006 at 11:55 PM.
naruto1327 is offline  
Old 07-19-2006, 12:49 AM   #2 (permalink)
Ape for Diddy
 
Beazel's Avatar
 
Join Date: Jun 2006
Location: Detroit, MI
Posts: 255
Reputation: 14
Default

I don't know much about C/C++, but this applies to all types of coding I do.

Indentation: Tab.
Bracket Placement: For one-liners, I use int main() {, for anything more than one line:
Code:
int main()
{
	std::cout << "lol, C++\n";
	cin.get();
}
Spaces between operators and declarations: Yes.
Spaces between function name and starting parenthesis: No.
Spaces between loop name and starting parenthesis: Yes.
Spaces for references and pointers: No.
Whether you omit the <int> in the following specialization: No clue what that is.
Beazel is offline  
Old 07-19-2006, 01:38 AM   #3 (permalink)
Dante’s Inferno
 
naruto1327's Avatar
 
Join Date: May 2006
Location: OLD PROFILE. NEW: NOODLEPOWA
Posts: 608
Reputation: 10
Send a message via AIM to naruto1327 Send a message via MSN to naruto1327 Send a message via Yahoo to naruto1327
Default

What about the int * n and int & n?

Thanks for replies!
naruto1327 is offline  
Old 07-19-2006, 02:52 AM   #4 (permalink)
Banned
 
TwitcH's Avatar
 
Join Date: May 2006
Posts: 2,053
Reputation: 14
Default

Quote:
Originally Posted by naruto1327
What about the int * n and int & n?

Thanks for replies!
I normally do:

int *n

And:

int &n

But im not a C++ coder, good old C for me
TwitcH is offline  
Old 07-19-2006, 03:12 AM   #5 (permalink)
Ape for Diddy
 
Beazel's Avatar
 
Join Date: Jun 2006
Location: Detroit, MI
Posts: 255
Reputation: 14
Default

Quote:
Originally Posted by naruto1327
What about the int * n and int & n?

Thanks for replies!
Spaces for references (&) and pointers (*): No.

Beazel is offline  
Old 07-20-2006, 04:04 AM   #6 (permalink)
Dante’s Inferno
 
naruto1327's Avatar
 
Join Date: May 2006
Location: OLD PROFILE. NEW: NOODLEPOWA
Posts: 608
Reputation: 10
Send a message via AIM to naruto1327 Send a message via MSN to naruto1327 Send a message via Yahoo to naruto1327
Default

So you do int&n and int&n, Beazel?

By the way, nice sig.
naruto1327 is offline  
Old 07-20-2006, 04:08 AM   #7 (permalink)
Crumbly, but Good
 
Eriond's Avatar
 
Join Date: May 2006
Location: Montreal
Posts: 1,618
Reputation: 57
Send a message via MSN to Eriond
Default

Code:
int main()
{
cout << "Hello." << endl;
for (c = 0; c < 10; c++){// (Haha, get it? C? C++? Haha? Aww.. you're no fun.)
LoopStuff()
MoreLoopStuff()
}
}
And always, always int* n. Helps reminding me that I'm not actually dealing with an int ^_^
Eriond is offline  
Old 07-20-2006, 04:15 AM   #8 (permalink)
Dante’s Inferno
 
naruto1327's Avatar
 
Join Date: May 2006
Location: OLD PROFILE. NEW: NOODLEPOWA
Posts: 608
Reputation: 10
Send a message via AIM to naruto1327 Send a message via MSN to naruto1327 Send a message via Yahoo to naruto1327
Default

So which way should I do it?
naruto1327 is offline  
Old 07-20-2006, 04:37 AM   #9 (permalink)
Banned
 
TwitcH's Avatar
 
Join Date: May 2006
Posts: 2,053
Reputation: 14
Default

Whichever way makes more sense to you.
TwitcH is offline  
Old 07-20-2006, 05:28 AM   #10 (permalink)
Dante’s Inferno
 
naruto1327's Avatar
 
Join Date: May 2006
Location: OLD PROFILE. NEW: NOODLEPOWA
Posts: 608
Reputation: 10
Send a message via AIM to naruto1327 Send a message via MSN to naruto1327 Send a message via Yahoo to naruto1327
Default

I think I'll do it the way Eriond does it.
naruto1327 is offline  
 

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 01:11 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0
OnRPG, Copyright ©2003-2011, Game Entertainment Enterprises