Eclipse Galileo is my favorite IDE for C++. It's free, open source, etc.
Anyway, brackets are a way to tell the compiler where to start a block of statements and where to end it. In other languages, these are often replaced by words, like ENDIF, or FI, or END, etc, and usually use the control statement as the initializer, omitting any kind of opening delimiter. If there were no opening/closing delimiters, the compiler/interpreter would not know where the block starts or ends.. C++ does not nessesarily have to have brackets around a single line block, i.e. you can do this
1 2 3 4
|
if (condition)
cout << "True" << endl;
else
cout << "False" << endl;
|
or this
1 2
|
if (condition) cout << "True" << endl;
else cout << "False" << endl;
|
But you cannot do this
1 2 3
|
if (condition)
cout << "Condition:" << endl;
cout << "true" << endl;
|
it has to be enclosed in brackets like so:
1 2 3 4 5
|
if (condition)
{
cout << "Condition:" << endl;
cout << "true" << endl;
}
|
Also note, that it doesn't matter where the brackets actually are, as long as they are before and after the statements in the block... such as:
1 2 3 4
|
if (condition) {
statement1;
statement2;
}
|
or
if (condition) { statement1; statement 2; }
Semicolons are End-Of-Statement or End-Of-Line (EOL) delimiters. They tell the compiler where a single statement ends, thus you can span single statements across multiple lines, or put multiple statements on the same line, unlike other languages.
Other languages would process
as two separate statements, while C/C++ will process things depending on where the delimiter is located, as in
it treats the two lines as a single statement, or single line. And will treat
statement1; statement2;
as separete statements, as if they were on different lines. This is powerful, but also dangerous because one can often forget to include a semicolon, and the program will not work...