No. I forget the technical term, but C++ allows for unlimited whitespace, but only in certain instances, like you
need to put white space between datatypes and a variable name, but you have the option of putting spaces and extra lines just about anywhere. My only suggestion is try to limit tons of whitespace. I've seen people post code who have 3-4 empty lines towards the end of their program, especially between closing braces.
As for what you were asking in regards to my previous posts, the indentation didn't affect the action of the while loop, the brackets did. The first two cases demonstrate how, without brackets, the loop only applies to the next statement. Typically a while statement will have brackets purely because unless you know what you're doing, it will run forever. Cases where brackets are omitted frequently is like in for loops and if conditions.
For Example:
1 2 3
|
if (false)
dontDoMe();
doMe();
|
In the example, you can see how dontDoMe() doesn't get run, but because a condition/loop that doesn't have brackets only affects the following statement, doMe() does get called. This is why I said the indentation will help a lot. When you start working with multidemensional arrays, you'll have nested for loops and the brackets can get in your way. I've already had four for loops that only affected one statement.
Another Example:
1 2 3 4 5 6
|
for (int i = 0; i < 2; i ++)
for (int j = 0; j < 2; j ++)
for (int k = 0; k < 2; k ++)
for(int l = 0; l < 2; l ++)
doMe();
fooBar();
|
From the code above, doMe() actually gets called 16 times. Each for loop will affect only the next thing after it, and nesting fors can be helpful, but can get messy too. If you don't know for loops yet, each loop runs exactly twice, well if the first one runs twice, the next one runs four times, and the next one runs 8 times, and the one after that runs 16 times, which is why doMe() gets called 16 times. Now fooBar() will only get called once since it's not following any of the loops. It's something worth trying out sometime so you understand how different things work.
Those were just some quick examples to show what happens when you don't use brackets. I can show you the same previous fors with brackets in the correct spaces:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
for (int i = 0; i < 2; i ++)
{
for (int j = 0; j < 2; j ++)
{
for (int k = 0; k < 2; k ++)
{
for(int l = 0; l < 2; l ++)
{
doMe();
}
}
}
}
fooBar();
|
Nothing changed except adding the "implied" brackets in. Does it make sense why sometimes certain things don't have brackets? It saves unnessecary lines, but some beginners find it easier to understand when you can see the physical scope of each loop.