Home > Back-end > Why class cannot like a function definition in the back of the main function?
Why class cannot like a function definition in the back of the main function?
Time:10-04
I read on the Internet explanation is: 1. Because the function declaration will know that the return type, you can use the return type at compile time allocated memory space, but not class,
Allocate space, I want to ask the compile time refers to the compile time for global variables or static variables are allocated space? Just only global or static variables need to be in the compiler allocates space?
In addition to the main function is only at run time space allocated on the stack, and compile time should also do not have what relation,
2. If the class definition on the back of the main function, the main function of the local object constructor of the class definition of what all don't know, could not instantiate,
I tried it really seems to be the problem, but should not be like function at compile time, into the symbol table? Or say that is not true?
For leaders to solve!
CodePudding user response:
Post your code???? Put the so-called doesn't define