You cannot have code outside functions except declarations, definitions, and preprocessor directives.
Is this statement accurate, or is there something I am missing? I teach my nephew a program, and he tried to put the cycle to the beginning. He is quite young, I want to give him a firm rule that he can understand.
Not really - you can also put expressions in global variable declarations:
int myGlobalVar = 3 + SomeFunction(4) - anotherGlobalVar;
, , . ( , if , ..). , main() , , . , .
if
main()
- .
, , - , , ( ).
This is because C ++ is a structured programming language that surrounds its behavior inside procedures, unlike unstructured ones in which you have only one level of code and no areas.
Well, there are namespaces ... and the stuff Adam Rosenfield talked about ... and there is also a try / catch exception, which can be kind of external to functions. Unfortunately, I cannot recall the syntax and cannot find it using Google.
Source: https://habr.com/ru/post/1771968/More articles:Entity Framework 4: Any way to learn plural form like Entity? - c #NLP Project Ideas - nlp@dynamic properties and its use? - propertiesDelphi, IXMLDOMDocument2, Downloading failed due to invalid character - xmlOracle Job failed for no reason - oracleTabs on an aspx page - asp.netBrowser-based strategy in Django / GAE. Model Suggestions? - google-app-engineAndroid Browser Versioning Event Continues Shooting - javascriptUsing Java generics in an interface to provide an implementation of a method with an implementation type as a parameter - javahow to find Wi-Fi location on iphone - iphoneAll Articles