Almost all the code I've seen until now uses the following style for curly braces:
void swap(int &a, int &b)
{
int temp = a;
a = b;
b = temp;
}
Visual Studio also defaults to this. However I have read Code Complete 2nd edition and Steve McConnell argues against this style. "Avoid unindented being-end pairs (...) Although this approach looks fine, it (...) doesn't show the logical structure of the code. Used this way, the begin and end aren't part of the control construct, but they aren't part of the statements after it either." Steve McConnell recommends using the pure block style, which emulates Visual Basic (where there's no curly braces):
void swap(int &a, int &b) {
int temp = a;
a = b;
b = temp;
}
or this (begin-end block boundaries):
void swap(int &a, int &b)
{
int temp = a;
a = b;
b = temp;
}
Although I tend to agree with McConnell's reasoning, all the books I read, the classes I attended, and Visual Studio, use the first style, so I find it a bit weird. What do you think?
Still hate Windows 11, I stuck it on my gaming machine again just for a nose to see what they had done, still as bad.
Will restore Windows 10 back on it, suit MS anyway, they don't want me to run Windows 11 on it.
Ms did go with the you must sign into an account thing with Windows 8 for a while. The same sort of thing they are doing with Windows now and the MS account.
Hello,
What sort of Microsoft Authenticator account login approval requests are you getting? It is a generic authentication app and can be used with all sorts of services (Microsoft Account, Google Account, websites and services that support multi-factor authentication, etc.).
Regards,
Aryeh Goretsky
Windows 8? Nah. I found Window 8 worked well, get a third party start menu to get rid of the start screen, I used Start is back and windows 8 was pretty good. I used it even when Windows 10 came out as I found Windows 10 was iffy on my machine at the time was AMD FX Bulldozer based. It was only when I updated the innards to Ryzen that I had no choice but to go to Windows 10 as MS made it difficult to stay with Windows 8.
ME, yes, that was not great, I liked the look of it, but it was not stable, shame really because Windows 98SE was the best of the dos based Windows.
Question
Andre S. Veteran
Almost all the code I've seen until now uses the following style for curly braces:
void swap(int &a, int &b) { int temp = a; a = b; b = temp; }Visual Studio also defaults to this. However I have read Code Complete 2nd edition and Steve McConnell argues against this style. "Avoid unindented being-end pairs (...) Although this approach looks fine, it (...) doesn't show the logical structure of the code. Used this way, the begin and end aren't part of the control construct, but they aren't part of the statements after it either." Steve McConnell recommends using the pure block style, which emulates Visual Basic (where there's no curly braces):
void swap(int &a, int &b) { int temp = a; a = b; b = temp; }or this (begin-end block boundaries):
void swap(int &a, int &b) { int temp = a; a = b; b = temp; }Although I tend to agree with McConnell's reasoning, all the books I read, the classes I attended, and Visual Studio, use the first style, so I find it a bit weird. What do you think?
Link to comment
https://www.neowin.net/forum/topic/630296-curly-braces-placement-and-indentation/Share on other sites
63 answers to this question
Recommended Posts