期刊文献+

C++ 虚函数机制及其实现 被引量:3

Virtual function of C++ and it's implementation
原文传递
导出
摘要 C++是面向对象语言中最引入注目,最具有广泛使用基础的语言之一。C++除保留了传统的和有效的结构化语言C的特征外,主要引进了支持面向对象程序设计的诸多语言特征,如类属、封装、继承和多态性等。C++中实现多态的一个重要机制是虚函数,常常使用它在父类中对某种操作提供一个框架,而在不同的子类中为该框架提供不同的实现。这种机制对编译程序的要求便是目标程序的动态绑定。因此介绍了在以C为目标语言的C++编译系统中,实现用于支持多态性的虚函数机制的方法。根据定义虚函数的父类和它们子类的继承关系的不同,分别针对单继承、多继承及虚父类中的虚函数的三种表现,讨论了构造虚函数表和修正函数入口地址的实现技术。 C ++ is one of the most popular languages to support object oriented programming. It is largely a superset of C. C ++ retains compatibility with C and particularly adds to C powerful new constructions, such as, generic, encapsulate, inheritance, and polymorphism. The virtual function is one of facilities to support polymorphism in C ++ . Normally the virtual function mechanism is used to provide the frame and the declaration of public methods of some operation for the parent or base class, then the implementation details of the operation could be given in the derived classes individually. The dynamic binding or late binding is the mean to implement virtual function in C ++ compiler. This paper introduces the technology to implement virtual function mechanism in C ++ compiler, whose target language is C. The main technology is constructing virtual function list and modifying entrance address of function according to different kinds of inheritance relationship.
出处 《清华大学学报(自然科学版)》 EI CAS CSCD 北大核心 1998年第S1期64-66,共3页 Journal of Tsinghua University(Science and Technology)
基金 国家"八五"科技攻关项目
关键词 对象 继承 虚函数 虚类 classes object inheritance virtual function virtual classes 
  • 相关文献

同被引文献10

引证文献3

相关作者

内容加载中请稍等...

相关机构

内容加载中请稍等...

相关主题

内容加载中请稍等...

浏览历史

内容加载中请稍等...
;
使用帮助 返回顶部