delphi – 将受保护部分中的方法限制为少数类
发布时间:2020-12-15 04:11:30 所属栏目:大数据 来源:网络整理
导读:我想限制受保护方法对某些继承类的访问. 例如,有一个基类 TBase = Class Protected Method1; Method2; Method3; Method4;End; 我有两个派生自TBase的课程 TDerived1 = Class(TBase) //Here i must access only Method1,Method2 and Method3End;TDerived2 = C
我想限制受保护方法对某些继承类的访问.
例如,有一个基类 TBase = Class Protected Method1; Method2; Method3; Method4; End; 我有两个派生自TBase的课程 TDerived1 = Class(TBase) //Here i must access only Method1,Method2 and Method3 End; TDerived2 = Class(TBase) //Here i must access only Method3 and Method4 End; 那么有可能吗? 解决方法
没有办法做到这一点.如果方法受到保护,则所有后代类都可以访问它.如果您有两组可以轻松划分的独立功能,则可能需要重新考虑类设计.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |