1- template function and normal function difference:
ordinary type conversion function can automatically
function template must strictly match the type.
2- template function call rules:
(1) function template can think of as ordinary functions can be overloaded.
(2) C ++ compiler priority to normal function.
(3) If the function template can produce a better match, then select a template.
(4) The compiler can only be defined by the template matching template empty argument list syntax.
3-C ++ compiler process:
compilation process: index.cpp >> >> precompiler compiler >> >> assembler connector
corresponding to generate the file: Index.cpp >> index.i >> index.s (compilation of documents) >> target file (in the windows is: .obj file; under Linux is: .o file) >> Index.exe
4-function template, template function:
function templates >> >> template function is called
a function template mechanism Conclusion :
the compiler does not handle the function template into any type of function;
function templates have different functions by specific types;
the compiler will function template twice compile, compile the template code itself in the place declared at call place the code after replacing the parameters to be compiled.
STL of 1- [template function and the difference between the ordinary function; 2- template function call rule; 3-C ++ compiler process; 4- function template, template function.
Guess you like
Origin blog.csdn.net/weixin_41747893/article/details/102801813
Recommended
Ranking