What are the modules? Why are they needed and how do they differ from the header files? When it is worth using one, and when the second?
Answer 1, Authority 100%
https://docs.microsoft. COM / RU-EN / CPP / CPP / MODULES-CPP? View = VS-2019
What are the modules?
Module is a set of source code files that are compiled regardless of the broadcast units that import them.
Why are they needed and how do they differ from the header files?
-
modules eliminate or significantly reduce many problems associated with
using header files, and can also reduce time
compilation. -
macros, preprocessor directives and uncomportable names,
declared in the module are not visible and therefore do not affect the compilation
Conversion recording that imports module. -
modules can be imported in any order without taking care of
Macros redefinitions. -
Announcements in the imported record are not involved in the resolution
Overload or search for names in the imported module. -
After compiling the module, the results are stored in a binary file,
which describes all exported types, functions and patterns. This
The file can be processed much faster than the header file, and
can be used by the compiler every time the module
Imported to the project.
When it is worth using one, and when the second?
It is recommended that new projects use modules, and not header files as far as possible. For large existing projects within the framework of active development, we recommend experimenting with the conversion of obsolete headers into modules to determine whether a meaningful reduction in compilation time will be obtained.