squirrely braces

This is not really a programming question but a more a programming practice question. I was wondering which is the best practice:
1
2
3
4
 int main(){
  cout << "Hello World";
  return 0;
}

or
1
2
3
4
5
int main()
{
  cout << "Hello World";
  return 0;
}

Which is the best way to use the braces?
Is there any experienced programmers out there that can answer that?
What do you suggest?
I've always seen the second version used. I would guess the reason is for clarity. If you see one brace, it's easy to look up or down and find its complement.
It is not a programming practice question but a syle one.
Answer: There is several styles which is used by different programmers/projects. It is not important which you prefer, it is your ability to adhere to project style you are working on which is important.
+1 for what miinipaa said. you can have your own personal style, but projects will require a certain way. my default example for this is webkit, which requires its code along that style
Just another thing that I feel I should add on - just because you see people doing one version does not necessarily mean its better. In this case, it is just the style preferred by most C++ programmers and style guides. However, if you come from a different background than C++, you'll often see people using the braces in a different way, which was more natural and common to their original language.

For example, most experienced people I see on these forums use the second version, but I use the second version (if slightly neater):
1
2
3
4
int main() {
    std::cout << "Hello World!\n";
    return 0;
}
When you work on group project you may have to use a particular style. This is to make it easier for others in the same project to read your code and combine it together. The key thing here is to maintain consistency. Reading code that is not consistent and jumps to one style and another becomes more confusing than it needs to be. Easily read code is well written code.
Topic archived. No new replies allowed.