Home > Back-end > About where the global variable function call is legal?
About where the global variable function call is legal?
Time:04-11
# include & lt; iostream>
Int the add (int a, int b) { STD: : cout & lt; Return (a + b); }
Int result1=add (4, 2);
Int main () { Int result=add (1, 2); return 0; }
Int result1=add (4, 2); Is a function of where the global call, not through the main () entry function, Vaguely remember can't do that, before the function call can't like ordinary variables in a global variable OuZhi or move, but the above code to run is correct, please correct me,
CodePudding user response:
So to write in c + + Will run in the main initialization before all need very quantity function called global variables
CodePudding user response:
C + +, C language compiler error, But anyway, so write is not recommended, code maintenance is a disaster,
CodePudding user response:
So write is not recommended.
CodePudding user response:
Look at the code it hurts head want to hit people
CodePudding user response:
Hello, you can probably say why C are not allowed to do it, in addition to maintain trouble, what is the fatal damage?