Consummating virtuality to support more polymorphism in C++

被引:0
|
作者
Chen, WK [1 ]
Sun, JS [1 ]
Tang, ZM [1 ]
机构
[1] BEIJING UNIV,DEPT COMP SCI,BEIJING 100871,PEOPLES R CHINA
关键词
object-oriented programming; polymorphism; virtuality; C++;
D O I
10.1145/261353.261362
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Inheritance together with virtual functions in C++ provides programmers much polymorphism, an important facility of object-oriented design and programming. However, they can hardly be applied to enrich a family of classes(including the base classes and their derived classes) with some common features. Multiple inheritance and virtual base classes are usually hired to solve such a problem, or templates can also be employed for the same purpose. Unfortunately, these approaches are unnatural and costly. Moreover, virtual base classes deflect from the concept of dynamic binding behind virtual functions and therefore complicate the incomplete virtuality in C++. In this paper, we demonstrate that truly virtual base classes can be utilized to solve the problem effectively and efficiently, and can be used to express explicitly what virtual base classes do implicitly in a more flexible and lucid way. In addition, they along with virtual data members can provide further polymorphism and a type-safe and efficient alternative to constrained genericity and multiple inheritance in some cases, and hence facilitate the design and implementation of extensible and portable software, especially libraries of classes.
引用
收藏
页码:61 / 68
页数:8
相关论文
共 50 条
  • [1] MORE C VS C++
    KENWORTHY, E
    [J]. DR DOBBS JOURNAL, 1993, 18 (10): : 14 - 14
  • [2] MAKING C++ MORE APPROACHABLE
    THE, L
    [J]. DATAMATION, 1993, 39 (02): : 37 - &
  • [3] VISUAL C++ - A MORE APPROACHABLE-C
    THE, L
    [J]. DATAMATION, 1993, 39 (15): : 36 - &
  • [4] Simple support for design by contract in C++
    Guerreiro, P
    [J]. TOOLS 39: TECHNOLOGY OF OBJECT-ORIENTED LANGUAGES AND SYSTEMS, PROCEEDINGS: SOFTWARE TECHNOLOGY FOR THE AGE OF THE INTERNET, 2001, 39 : 24 - 34
  • [5] Class library adds C++ support
    Moretti, G
    [J]. EDN, 2002, 47 (06) : 17 - 17
  • [6] Support for Parallel and Concurrent Programming in C++
    N. I. V’yukova
    V. A. Galatenko
    S. V. Samborskii
    [J]. Programming and Computer Software, 2018, 44 : 35 - 42
  • [7] MORE C++ AND A STEP UP TO ANSI-C
    STEVENS, A
    [J]. DR DOBBS JOURNAL, 1989, 14 (10): : 123 - &
  • [8] Yet, more web exercises for learning C++
    Elenbogen, BS
    Maxim, BR
    McDonald, C
    [J]. SIGCSE 2000: PROCEEDINGS OF THE THIRTY-FIRST SIGCSE TECHNICAL SYMPOSIUM ON COMPUTER SCIENCE EDUCATION, 2000, 32 (01): : 290 - 294
  • [9] C++ - EVOLVING TOWARD A MORE POWERFUL LANGUAGE
    COPLIEN, JO
    DEWHURST, SC
    KOENIG, AR
    [J]. AT&T TECHNICAL JOURNAL, 1988, 67 (04): : 19 - 32
  • [10] STL and generic programming - More on C++ metaprogramming
    Becker, Thomas
    [J]. C/C++ Users Journal, 2002, 20 (10):