摘要
多重继承一直是C++语言中一个广受争议的语言特征。一般认为,在面向对象设计中应该谨慎使用多重继承。文章分析了C++中多重继承实现的复杂性并对如何高效使用多重继承进行了探讨。作为替代方案,文中给出了基于内部类的方法以避免多重继承的复杂性,并对内部类机制在面向对象设计中的应用进行了探讨。
Multiple Inheritance(MI) is just another tool in the object-oriented toolbox.Compared to single inheritance,it's typically more complicated to use and more complicated to understand.In this paper,we present the "dark corner" of MI and give guide on how to use MI effectively in OO design.As an ahernative,inner class mechanism can emulate MI cleanly while avoiding the complexity and efficiency drawbacks of MI.we present the inner class emulation in C++ by code sample and discuss the application of inner class in OO design.
出处
《计算机工程与应用》
CSCD
北大核心
2006年第20期92-94,共3页
Computer Engineering and Applications
基金
国家863高技术研究发展计划资助项目(编号:2002AA114020
2001AA135210)
中国科学院知识创新项目资助(编号:20036020)
关键词
内部类
C++
多重继承
面向对象设计
inner class, C++, Multiple Inheritance,Object-Oriented design