比如一个函数完成后提示 完成了,这个提示放在main好还是函数里?在看primer plus感觉作者倾向于前者,函数简单,但是main看起来很多
PHPz2017-04-18 09:50:13
Define a private logger
。在函数执行各个阶段往logger
里打日志。在logger
with a settergetter method in the class. The configuration specifies the level that needs to be printed to the screen.
迷茫2017-04-18 09:50:13
Since we want to prompt the function to complete, the function completion sign is normal return, so it is better to do it in main
怪我咯2017-04-18 09:50:13
It is better to keep main simple. MFC and the like do not even use main directly, but implement program initialization through the constructor of the global object AppInstance. Specific logic is best encapsulated into classes.
黄舟2017-04-18 09:50:13
There is no doubt that it is more appropriate to prompt the status in a specific function. The main function is the entry point of the program, and it is impossible to prompt the status of all functions and classes. For example, if a function calls another function, this nesting cannot be seen in the main function, so how can the status be prompted in the main function.