Difference between Override and Reintroduce in Delphi
来源:互联网 发布:上搜狐知天下 编辑:程序博客网 时间:2024/06/05 00:45
原文地址:http://techblogsearch.com/a/difference-between-override-and-reintroduce-in-delphi.html
Difference between Override and Reintroduce in Delphi
When you decide to declare a method as virtual, you are giving permission to derived classes to extend and override the method with their own implementation.
当你决定去声明一个虚方法时,就表示你给了继承类用他们自己的实现去扩展获取重写这个方法的许可。
Use the reintroduce keyword to introduce a new implementation of a parent method (this hides the parent method). You can hide a method without using reintroduce but you will get a compiler warning. Using reintroduce will suppress the warning.
You tell the compiler that you know that you hide the ancestor function and replace it with this new function and do so deliberately.
Difference between Override and Reintroduce
1. The reintroduce and override modifiers have different meanings. The reintroduce modifier creates a new member with the same name, signature, and visibility and hides the original member. The override modifier extends the implementation for an inherited member and allows you to implement inheritance-based polymorphism.
2. Override is used in conjuction with Virtual/Dynamic methods of parent class but for Reintroduce, parent method should not be necassarily Virtual/Dynamic.
The only reason to override an ancestor method is that you can call inherited from within the descendent method. If you don't intend to call inherited from within a descendent method, the descendent method should be declared with Reintroduce rather than Override.
Avoid Reintroduce
Sometimes there are clear reasons to introduce a new method with the same name, signature, and visibility of a parent method. In those clear cases, introducing a new member is a powerful feature. However, if you do not have a clear reason, then avoid using Reintroduce.
0 0
- Difference between Override and Reintroduce in Delphi
- override overload reintroduce的区别(delphi)
- Difference between STA and MTA in thread
- Difference between Externalizable and Serializable in Java
- Difference between Vector and ArrayList in java?
- Difference between Comparator and Comparable in Java
- Difference between TreeMap and TreeSet in Java
- Difference between RegularEnumSet and JumboEnumSet in Java
- Difference between __str__ and __repr__ in Python
- Difference Between Thread and AsyncTask in Android
- Difference between Comparator and Comparable in java
- Difference between Stack and Heap in Java
- Difference between dialog and session in SIP?
- Difference between ArrayList and Vector In java
- Difference between Controller and Model in MVC
- Difference between datacontract and messagecontract in wcf
- 【Struts0002】Difference between # , $ and % signs in Struts2
- Difference between HashMap and Hashtable in Java
- php下载文件并重命名
- clion 拷贝可执行程序到本目录
- JQuery validate验证规则
- 2016/11/3 1002. 二叉树
- angularJs Demo1
- Difference between Override and Reintroduce in Delphi
- poj-3041【二分图最小顶点覆盖】
- AIDL简析使用
- 时间段或时间点重合判断
- Ubuntu 升级源repo改为阿里云源
- 第一次开通博客
- 线程与进程的区别
- Java ArrayList(AbstractList)之 modCount++ 此字段属性的英文注释翻译。
- ARM官方《CMSIS-RTOS教程》之创建线程Creating Threads