Wht is static and dynamic bindings in c plus plus?In: C Programming
[Edit categories]
|
Dynamic binding is where the linker copies only a stub code for the referenced module into the executable image. That stub code loads the referenced module into memory at load/run time.
Advantage of static is simplicity. The executable is stand-alone. Disadvantage is the executable image is larger, and if the referenced module changes, then each executable that uses it must be relinked. Another disadvantage is that if you have more than one executable using the module at the same time, you must have multiple copies of it in memory.
Advantage of dynamic is reduced size of the executable image and that changing the referenced module does not require relink of the executable. Another advantage is that most operating systems can share the referenced module, meaning that only one copy of the referenced module need exist in all of memory for any number of references to that module, such as from multiple instances of the executable. Disadvantage of dynamic is that the executable is dependent on the shared library at run time. Another disadvantage is that, since the module is shared, it must be reentrant and thread safe, and this is not always done correctly.
First answer by Alex146. Last edit by Alex146. Contributor trust: 96 [recommend contributor]. Question popularity: 1 [recommend question].



