Possible Duplicate:
Why must I put a semicolon at the end of class declaration in C++?
Found duplicate, vote to close please.
Why do classes and structs have to be concluded with semicolon in C++?
Like in the following code:
class myClass
{
};
struct muStruct
{
};
This syntax isn't necessary in Java or C#. Why does the C++ parser need it?
A semicolon after a close brace is mandatory if this is the end of a declaration. In case of braces, they have used in declarations of class, enum, struct, and initialization syntax. At the end of each of these statements, we need to put a semicolon.
At the end of a struct definition a semicolon is not required. However at the end of a struct tuple it is.
When you first start working with while statements, you might accidentally place a semicolon after the “while(true/false expression)” part of the statement such as shown below. The semicolon results in a null statement, a statement that does nothing.
Because the next word following the }
may declare a variable of said type. This is a relic from C:
struct S { int a; } s;
s.a;
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