static is binding before run-time where as dynamic is binding during run-time.
e.g.
int my = 2;
Static binding means that whenever the
code refers to a particular symbol, variable, etc., after the program is compiled that symbol is hard-coded to point to a particular thing, so the computer doesn't have to waste time looking the thing up.
Dynamic binding means that programs have to make binding decisions, in some form, at run-time.
eg :
* using malloc() function you are allocating memory at runtime.
* When allocating value to function pointer at runtime.
2007-02-02 04:58:39
·
answer #1
·
answered by check 1
·
0⤊
0⤋
Static And Dynamic Binding
2016-10-30 07:09:05
·
answer #2
·
answered by ? 4
·
0⤊
0⤋
For the best answers, search on this site https://shorturl.im/axjw7
When you have a pointer to an object, the object may actually be of a class that is derived from the class of the pointer (e.g., a Vehicle* that is actually pointing to a Car object; this is called "polymorphism"). Thus there are two types: the (static) type of the pointer (Vehicle, in this case), and the (dynamic) type of the pointed-to object (Car, in this case). Static typing means that the legality of a member function invocation is checked at the earliest possible moment: by the compiler at compile time. The compiler uses the static type of the pointer to determine whether the member function invocation is legal. If the type of the pointer can handle the member function, certainly the pointed-to object can handle it as well. E.g., if Vehicle has a certain member function, certainly Car also has that member function since Car is a kind-of Vehicle. Dynamic binding means that the address of the code in a member function invocation is determined at the last possible moment: based on the dynamic type of the object at run time. It is called "dynamic binding" because the binding to the code that actually gets called is accomplished dynamically (at run time). Dynamic binding is a result of virtual functions.
2016-04-08 22:32:18
·
answer #3
·
answered by Anonymous
·
0⤊
0⤋
http://www.cs.wustl.edu/~schmidt/PDF/C++-dynamic-binding4.pdf
2007-02-02 04:27:10
·
answer #4
·
answered by iyiogrenci 6
·
0⤊
0⤋