# Indent styles

This topic is 3493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

class ClassName
{
...
};
void functionName( ... )
{
...
};


It is so common and may be found in the MSVC++, Windows SDK and DirectX, as well as a lot of other sources. It is also used in combination with the K&R style for classes, structs, etc. except for control structures like if, while, etc.
void functionName( ... )
{
struct StructName
{
...
};
if( ... ) {  // K&R style
while( ... ) {
...
}
}
};


It is the recommended style in many guidelines: http://www.gamedev.net/reference/articles/article708.asp http://geosoft.no/development/cppstyle.html ... However, in the book "Code Complete 2nd ed" states that this style breaks the logical structure of the code, and a pure K&R or the Whitesmiths style (I personally dislike it) are better. What do you think guys? I still think that placing the braces in another line in classes, structs, enums, functions... and placing it on the same line for if, switch, while, for... looks much better. Also, I'm wondering what to do with namespaces. Since all my engine is placed within the same one, I have to indent the whole code in almost every header, like this:
namespace name
{
// All definitions intended
}


What would you do? Thank you a lot!!! :)

##### Share on other sites
There's been a lot of past discussion of coding styles in this forum... a google search should turn up plenty of info.

##### Share on other sites

This topic is 3493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

This topic is now closed to further replies.

1. 1
2. 2
Rutin
15
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633270
• Total Posts
3011156
• ### Who's Online (See full list)

There are no registered users currently online

×