静态绑定和动态绑定有什么区别? [英] What is the difference between static and dynamic binding?
本文介绍了静态绑定和动态绑定有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
绑定时间可以分为两种:静态和动态.静态绑定和动态绑定有什么区别?
Binding times can be classified between two types: static and dynamic. What is the difference between static and dynamic binding?
您能否给出一个简短的例子来进一步说明它?
Could you give a quick example of each to further illustrate it?
推荐答案
在最笼统的术语中,静态绑定意味着引用在编译时被解析. >
In the most general terms, static binding means that references are resolved at compile time.
Animal a = new Animal();
a.Roar(); // The compiler can resolve this method call statically.
动态绑定是指在运行时 解析引用.
Dynamic binding means that references are resolved at run time.
public void MakeSomeNoise(object a) {
// Things happen...
((Animal) a).Roar(); // You won't know if this works until runtime!
}
这篇关于静态绑定和动态绑定有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文