抽象和虚拟 [英] abstract and virtual

查看:102
本文介绍了抽象和虚拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抽象和虚拟之间有什么区别?

What is the difference between abstract and virtual?

推荐答案

在某些情况下,您无法提供某些方法的实现,但
方法必须存在,因为它是类接口的一部分.你要
使用类提供这些实现的程序员,您不会
想让他们实例化此类的对象,因为没有这个
方法不会简单地起作用.在这种情况下,您声明方法和
类作为抽象.无法实例化抽象类,因为它们是
不完整.


在其他情况下,您可以提供以下方法的默认实现:
即使没有重新定义也足以使控件正常工作,但是您想要
给使用您的班级作为基础班级的程序员提供他们的
更好的实施.在这种情况下,您将方法声明为虚拟方法,
给程序员提供选择是否使用默认值或提供其
的选项 自己的实现或是否使用默认设置并对其进行调整
结果.


有关更多信息,请访问此
http://stackoverflow.com/questions/755285/abstract-methods- vs-virtual-methods-in-c-sharp

http://msdn.microsoft.com/en-us/library/6tcf2h8w (v = VS.71).aspx [
In some cases you cannot provide a implementation for some methods, but
method have to be there because it is part of the class interface. You want
the programmers using the class to provide this implementation and you don''t
want to let them instantiate objects of this class because without this
method it won''t simply work. In this case you declare the method and the
class as abstract. Abstract classes cannot be instantiated because they are
not complete.


In other cases you can provide a default implementation of a method which is
good enough to make the control work even if not re-defined, but you want to
give the programmers using your class as a base class to provide their
better implementation. In this case you declare the method as virtual thus,
giving the progammers options whether to use the default or provide their
own eomplementation or if they which to use the default and tweak the
results.


for more info visit this
http://stackoverflow.com/questions/755285/abstract-methods-vs-virtual-methods-in-c-sharp

http://msdn.microsoft.com/en-us/library/6tcf2h8w(v=VS.71).aspx[^]


请参阅这些

抽象方法与虚拟方法 [ ^ ]

http://stackoverflow.com/questions/2454713/what-is- a-difference-between-abstract-and-virtual [ ^ ]
Refer these

difference between an abstract method & virtual method[^]

http://stackoverflow.com/questions/2454713/what-is-a-difference-between-abstract-and-virtual[^]


请参阅以下链接

http://www.differencebetween.com/difference-between-virtual-and-vs-abstract / [ ^ ]

http://stackoverflow.com/questions/391483/什么是抽象功能和虚拟功能之间的差异 [ http://bytes.com/topic/c-sharp/answers/533231- diff-between-virtual-abstract [ ^ ]

http://www.c-sharpcorner.com/Forums/线程/2750/difference-between-abstract-and-virtual.aspx [ http://stackoverflow.com/questions/755285/abstract-methods- vs-virtual-methods-in-c-sharp [ ^ ]
Refer these links

http://www.differencebetween.com/difference-between-virtual-and-vs-abstract/[^]

http://stackoverflow.com/questions/391483/what-is-the-difference-between-abstract-function-and-virtual-function[^]

http://bytes.com/topic/c-sharp/answers/533231-diff-between-virtual-abstract[^]

http://www.c-sharpcorner.com/Forums/Thread/2750/difference-between-abstract-and-virtual.aspx[^]

http://stackoverflow.com/questions/755285/abstract-methods-vs-virtual-methods-in-c-sharp[^]


这篇关于抽象和虚拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆