摘要
在如C++等强类型面向对象语言中,因仅能通过继承结合虚函数来表达某些动态多态性,从而难以自然有效地描述给某一族类中的各个类都添加一些共同特性.文中提出的真正虚基类和虚数据成员概念及相应的语言机制可用来方便地解决上述问题,同时又可消除C++中虚函数与虚基类概念上的不一致,改进和完善强类型面向对象语言中的虚机制,增强其多态性方面的表达能力,并且在多数情况下可以安全、有效地代替受限类属机制和多继承,从而方便可扩展和可移植软件。
Inheritance combined with virtual functions in strongly typed object oriented programming languages,such as C++,provides programmers with much polymorphism.However,it is difficult to enrich each of a family of classes with some common features.Here proposed are the concepts of truly virtual base classes and virtual data members,which can be utilized to solve the problem efficiently,eliminate the conceptual inconsistency between virtual functions and virtual base classes in C++,and consumate the virtuality so as to provide further polymorphism and a type safe and efficient alternative to constrained genericity and multiple inheritance in some cases,thus facilitating the design and implementation of extensible and portable software,especially,that of libraries of classes.
出处
《计算机研究与发展》
EI
CSCD
北大核心
1998年第7期599-604,共6页
Journal of Computer Research and Development
基金
国家攀登计划项目
关键词
面向对象
多态性
虚机制
C++语言
object orientation,polymorphism,virtuality,object oriented programming languages,C++