简体   繁体   English

“最派生类的ctor需要直接调用虚拟基类的ctor”语句的原始内容在哪里?

[英]Where is the original of the statement “the most derived class's ctor needs to directly call the virtual base class's ctor”?

While I learn how to implement a final class in C++, I find such a statement: 当我学习如何在C ++中实现最终类时,我发现了这样一条语句:

"the most derived class's ctor needs to directly call the virtual base class's ctor." “最派生类的ctor需要直接调用虚拟基类的ctor。”

However, I can't find the original of the statement in the C++ standard. 但是,我在C ++标准中找不到该语句的原始内容。 (N3126) (N3126)

Who can tell me the exact page number? 谁能告诉我确切的页码?

Thanks in advance. 提前致谢。

In C++03, it's § 12.6.2 5 在C ++ 03中,它是§12.6.2 5

Initialization shall proceed in the following order: 初始化应按以下顺序进行:

— First, and only for the constructor of the most derived class as described below, virtual base classes shall be initialized in the order they appear on a depth-first left-to-right traversal of the directed acyclic graph of base classes, where “left-to-right” is the order of appearance of the base class names in the derived class base-specifier-list. —首先,并且仅对于如下所述的最大派生类的构造函数,虚拟基类应按照它们在基类的有向无环图的深度优先从左到右遍历时出现的顺序进行初始化,其中“ “从左到右”是基类名称在派生类base-specifier-list中的出现顺序。

... ...

In the current draft for C++0x (N3126), it's § 12.6.2 10, which is page 270: 在C ++ 0x(N3126)的当前草案中,它是§12.6.2 10,即第270页:

In a non-delegating constructor, initialization proceeds in the following order: 在非委托构造函数中,初始化按以下顺序进行:

— First, and only for the constructor of the most derived class (1.8), virtual base classes are initialized in the order they appear on a depth-first left-to-right traversal of the directed acyclic graph of base classes, where “left-to-right” is the order of appearance of the base classes in the derived class base-specifier-list —首先,并且仅对于最派生类(1.8)的构造函数,虚拟基类将按照它们在基类的有向无环图的深度优先的从左到右遍历时出现的顺序进行初始化,其中“左“从右到右”是基类在派生类base-specifiner-list中的出现顺序

... ...

N3126 is not the C++ standard. N3126 不是 C ++标准。

It's a draft for the upcoming C++ standard. 这是即将到来的C ++标准的草案。

But anyway, the info about initialization is in the section about initialization for derived classes. 但是无论如何,有关初始化的信息在有关派生类的初始化的部分中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 虚拟继承:Base Ctor没有调用Most Derived Class? - Virtual Inheritance : Base Ctor not calling in Most Derived Class? 在派生类中使用虚拟基类中的受保护ctor - use protected ctor from virtual base class in derived class 出乎意料地能够从基类ctor调用派生类虚函数 - Unexpectedly able to call derived-class virtual function from base class ctor 是否有必要为虚拟继承中的最基类设置默认构造函数? - Is it necessary to have default ctor for the most-base class in virtual inheritance? 在派生类中使用基类Copy CTOR - Use base class Copy CTOR in derived class 将使用基类ctor创建的对象转换为派生类 - convert an object created with base class ctor to a derived class 派生类中基类委派的ctor的c ++使用 - c++ usage of delegated ctor from base class in derived class 实例化派生类对象,其基类ctor是私有的 - Instantiate a derived class object, whose base class ctor is private 如何使用派生Ctor中模板基类的typedef? - How to use typedef from template base class in Ctor of the Derived? 如果我们销毁 class 最基本的 class 是普通可破坏的(或不可破坏的)并且它的派生类的析构函数是虚拟的,那是 UB - Is that UB if we destory the class which the most base class is trivially destructible(or not) and it's derived class' destructor is virtual
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM