Another 2:00am one
-
That's caught by most compilers. But this one won't be :-
if (x == y)
doSomethingPart1();
doSomethingPart2();
. . .when you meant to do
if (x == y)
{
doSomethingPart1();
doSomethingPart2();
}
. . .Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
Currently working on C++/CLI in Action for Manning Publications. Also visit the Ultimate Toolbox blog -
That's caught by most compilers. But this one won't be :-
if (x == y)
doSomethingPart1();
doSomethingPart2();
. . .when you meant to do
if (x == y)
{
doSomethingPart1();
doSomethingPart2();
}
. . .Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
Currently working on C++/CLI in Action for Manning Publications. Also visit the Ultimate Toolbox blogThat's why you ALWAYS, ALWAYS should enclose the statement (even a single one) in braces. Even if omit them because you're 100% sure that only one statement is required in the if() or else body, it will bite you somewhere in the future (Sure, 100%...)
Cees Meijer Software / Hardware Engineer QMetrix BV Specialists in River and Sea flow measurements.
-
That's why you ALWAYS, ALWAYS should enclose the statement (even a single one) in braces. Even if omit them because you're 100% sure that only one statement is required in the if() or else body, it will bite you somewhere in the future (Sure, 100%...)
Cees Meijer Software / Hardware Engineer QMetrix BV Specialists in River and Sea flow measurements.
Cees Meijer wrote:
That's why you ALWAYS, ALWAYS should enclose the statement (even a single one) in braces. Even if omit them because you're 100% sure that only one statement is required in the if() or else body, it will bite you somewhere in the future (Sure, 100%...)
Yep, I always use braces even if it's just one statement. The code looks cleaner too.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
Currently working on C++/CLI in Action for Manning Publications. Also visit the Ultimate Toolbox blog -
Cees Meijer wrote:
That's why you ALWAYS, ALWAYS should enclose the statement (even a single one) in braces. Even if omit them because you're 100% sure that only one statement is required in the if() or else body, it will bite you somewhere in the future (Sure, 100%...)
Yep, I always use braces even if it's just one statement. The code looks cleaner too.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
Currently working on C++/CLI in Action for Manning Publications. Also visit the Ultimate Toolbox blog -
ditto
You may be right
I may be crazy
-- Billy Joel --Within you lies the power for good, use it!!!
-
That's why you ALWAYS, ALWAYS should enclose the statement (even a single one) in braces. Even if omit them because you're 100% sure that only one statement is required in the if() or else body, it will bite you somewhere in the future (Sure, 100%...)
Cees Meijer Software / Hardware Engineer QMetrix BV Specialists in River and Sea flow measurements.
Cees Meijer wrote:
it will bite you somewhere in the future (Sure, 100%...)
Yeah, especialy when you forget about it and add more to it. :/ You're lucky if there was an ELSE (the compiler should spit out an error about ELSE without an IF statement)...