Is there a specific reason why some people put a semicolon after the curly closing function bracket?
void foo() { };
C++ semicolon is used to tell the compiler where a statement ends. The body of a function or any scope block isn't a statement in and of itself so it's pretty much only needed after } when defining an object.
Do not use a semicolon on the same line as an if , for , or while statement because it typically indicates programmer error and can result in unexpected behavior.
JavaScript Learn JavaScript Quick Course BeginnersAdding semicolons after every function is optional. To avoid undesirable results, while using functions expressions, use a semicolon.
This is all possible because JavaScript does not strictly require semicolons. When there is a place where a semicolon is needed, it adds it behind the scenes. This is called Automatic Semicolon Insertion.
Not really, the semicolon there makes no difference. It's probably a matter of habit.
You can put as many semicolons if you want though in C++11:
void foo() { };;;;;;;;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With