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 条
  • [31] Standard C/C++: Testing C++ library conformance
    Plauger, P.J.
    [J]. C/C++ Users Journal, 2000, 18 (04):
  • [32] C++
    [J]. JOOP - Journal of Object-Oriented Programming, 1998, 10 (09):
  • [33] C++
    Koenig, Andrew
    [J]. 1998, (11):
  • [34] C++ for ...
    Stevens, A
    [J]. DR DOBBS JOURNAL, 1999, 24 (08): : 99 - 101
  • [35] C++
    [J]. JOOP J Object Oriented Program, 3 (71):
  • [36] C++
    [J]. JOOP J Object Oriented Program, 6 (85):
  • [37] HP C++/SOFTBENCH - A DEVELOPMENT ENVIRONMENT FOR C++
    ARMISTEAD, M
    BURNHAM, J
    [J]. JOURNAL OF OBJECT-ORIENTED PROGRAMMING, 1990, 3 (04): : 82 - &
  • [38] Stepping up to C++: Understanding C++ declarations
    Saks, Dan
    [J]. C/C++ Users Journal, 1995, 13 (12):
  • [39] The DREAM library support for PCD and RTO.k programming in C++
    Kim, KH
    Subbaraman, C
    Kim, Y
    [J]. SECOND WORKSHOP ON OBJECT-ORIENTED REAL-TIME DEPENDABLE SYSTEMS, PROCEEDINGS OF WORDS '96, 1996, : 59 - 68
  • [40] Towards scalable virtuality in C plus
    Nicart, Florent
    [J]. SOFTWARE-PRACTICE & EXPERIENCE, 2008, 38 (14): : 1451 - 1473