网站首页  英汉词典

请输入您要查询的英文单词:

 

单词 Virtual base class
释义

Virtual base class

英语例句库

The shared base-class subobject is called a virtual base class .

共享的基类子对象称为虚基类。

中文百科

虚继承 Virtual inheritance

(重定向自Virtual base class)
菱形类继承图示。
对于继承概念中的虚函数,请参阅虚函数。

虚继承 是面向对象编程中的一种技术,是指一个指定的基类,在继承体系结构中,将其成员数据实例共享给也从这个基类型直接或间接派生的其它类。

举例来说:假如类A和类B各自从类X派生(非虚继承且假设类X包含一些数据成员),且类C同时多继承自类AB,那幺C的对象就会拥有两套X的实例数据(可分别独立访问,一般要用适当的消歧义限定符)。但是如果类AB各自虚继承了类X,那幺C的对象就只包含一套类X的实例数据。对于这一概念典型实现的编程语言是C++。

这一特性在多重继承应用中非常有用,可以使得虚基类对于由它直接或间接派生的类来说,拥有一个共同的基类对象实例。避免由于带有歧义的组合而产生的问题(如“菱形继承问题”)。其原理是,间接派生类(C)穿透了其父类(上面例子中的AB),实质上直接继承了虚基类X

英语百科

Virtual inheritance 虚继承

(重定向自Virtual base class)
For inheritance of virtual functions, see virtual function.

Virtual inheritance is a technique used in C++, where a particular base class in an inheritance hierarchy is declared to share its member data instances with any other inclusions of that same base in further derived classes. For example, if class A is normally (non-virtually) derived from class X (assumed to contain data members), and if class B is also derived from class X, and class C inherits from both classes A and B, it will contain two sets of the data members associated with class X (accessible independently, often with suitable disambiguating qualifiers). But if class A is virtually derived from class X instead, then objects of class C will contain only one set of the data members from class X.

随便看

 

英汉网英语在线翻译词典收录了3779314条英语词汇在线翻译词条,基本涵盖了全部常用英语词汇的中英文双语翻译及用法,是英语学习的有利工具。

 

Copyright © 2004-2024 encnc.com All Rights Reserved
更新时间:2025/6/23 6:29:22