python - 请教c++项目中,一般是类里的函数具体点好,还是main中具体点好
PHP中文网
PHP中文网 2017-04-18 09:48:13
0
4
441

比如一个函数完成后提示 完成了,这个提示放在main好还是函数里?在看primer plus感觉作者倾向于前者,函数简单,但是main看起来很多

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
PHPzhong

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.

迷茫

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

刘奇

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.

黄舟

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template