First of all, I use user-defined header and corresponding cpp file. Then I include and so on. If I would switch to DLL, would the execution speed of the code be retarded?
Secondly, I know that in “DLL”, “D” represents “dynamic” however, my friend said that there are two ways to use them: Statically and dynamically. If it is dynamic already, what we have to do with “static”?
Unless the function is very small (so it gets inlined otherwise), using a DLL has no difference whatsoever on the performance (aside from the fact that loading a DLL does increase the startup time of your application.) Large, performance-critical applications use DLLs (for instance the Intel Math library.) There are minor penalties if the compiler cannot do whole-program optimization, but these are very small differences which usually don’t matter.
Regarding static/dynamic: I assume he means that you can link against a DLL the normal way (by using an import library), which forces it to be always loaded or load it dynamically at run-time (using
LoadLibraryanddlopen.) No performance difference there, but usingLoadLibraryallows you to delay loading the library until actually needed.