Understanding Dynamic Linking

I understand how dynamic linking works, as well as the difference between static and dynamic linking. I'm just having trouble moving my brain around the definition of dynamic binding. Basically, this is not a type of binding at runtime.

+3
source share
2 answers

In principle, dynamic linking means that the address for calling the function is not encoded in the code segment of your program when it is translated into assembly language, but instead is obtained from another place, i.e. stack variables, array search, etc.

At a higher level, if you have a line of code:

foo(bar) //Calls a funciton

, , . foo , , .

+3

, . , . , . , .

:

class Animal
{
void talk();
}

class Dog extends Animal
{
public void talk() { System.out.println("woof"); }
}

class Cat extends Animal
{
public void talk() { System.out.println("meow"); }
}

....
Animal zoo[2];
zoo[0] = new Dog();
zoo[1] = new Cat();

for(Animal animalToggle: zoo)
{
animalToggle.talk();
}

:

, , .

+1

Source: https://habr.com/ru/post/1699024/


All Articles