Answer the question
In order to leave comments, you need to log in
Why is there a semicolon after a class definition, but not after a function definition?
The essence of the question is very simple - why is there a semicolon after the class definition, but not after the function definition? At first I thought that this was due to the fact that both the declaration and the definition occur in one place, but, on the other hand, the situation is the same with the function.
struct Y
{
// ...
};
void someFoo()
{
// ...
}
Answer the question
In order to leave comments, you need to log in
a function definition always ends after the } symbol , but a class definition does not always.
Because in fact, a class declaration is a variable declaration (I don’t express myself quite correctly, but let’s say).
And in C++, when they write,
they put a semicolon.
similar:
class Foo
{
int a_;
} foo;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question