开发者

Why are certain bracket style/formats prefered in c/c++? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_JAVA百科 Closed 12 years ago.

I've gotten the gist that the following

<T> my_function(...) {
   ....
}

is preferred by most, compared to:

<T> my_function(...) 
{
   ....
}

Likewise for:

if (...) {
   ...
}

being preferred over

if (...) 
{
   ...
}

Is this true and if so, why is the former style preferred over the latter?


This isn't necessarily preferred - they're different styles, and different teams have their own preferences.

Many people prefer the former because the code becomes shorter and more "concise". Many people prefer the latter because it's easier, at a glance, to see that the opening parenthesis character was put in place. However, these are both preferences, and different people prefer different things (and even different than the ones you displayed, such as using indented parens, etc).


The first one is popular mostly, because it is demanded by Sun (Now: Oracle) in Java

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜