+ 3
Why don't #include <...> require a semicolon?
Programming Language: C & C++ Repeat: Why don't #include <...> require a semicolon? Possible reason?: Because like in function definition or class declaration you don't need to have semicolon after the codeblock.
7 Respostas
+ 6
#includes and other # are part of the preprocessor and is run before the compilation phase.
For a #include, code that is going to be included is copy pasted there which has their own ;'s.
Also for functions, classes and loops { } are used to mark the end instead of ; and at the end of a class a ; is required because there is another field after the } that needs to be closed.
+ 7
I think that's because that part of the code isn't intended for the compiler but for the preprocessor which uses its own syntax. I only know that you can't use a semicolon after #define because that would insert semicolons everywhere in the code. #define NUM 50; would lead to every "NUM" being replaced with "50;", not "50" 😶
+ 5
Preprocessor directives don't need semicolons.
+ 4
Ipang answers for your guestions cleared something for me too.
+ 2
Dennis There is another field at the end of class definition block? what field is that please?
class MyClass {
...
} < a field in here? >;
+ 2
Ipang Yea, you can specify object names after the }, seperated by ,'s, which are then constructed immediately.
You can get away with anonymous classes that way. :)