久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

是否在初始化變量之前調用了父類構造函數?

Are parent class constructors called before initializing variables?(是否在初始化變量之前調用了父類構造函數?)
本文介紹了是否在初始化變量之前調用了父類構造函數?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

是在初始化變量之前調用父類的構造函數,還是編譯器會先初始化類的變量?

Are parent class constructors called before initializing variables, or will the compiler initialize the variables of the class first?

例如:

class parent {
  int a;
public:
  parent() : a(123) {};
};

class child : public parent {
  int b;
public:
            // question: is parent constructor done before init b?
  child() : b(456), parent() {};
}

推薦答案

是的,基類在派生類成員和構造函數體執行之前初始化.

Yes, the base class is initialized before the members of the derived class and before the constructor body executes.

在非委托構造函數中,初始化在以下順序:

In a non-delegating constructor, initialization proceeds in the following order:

——首先,并且只針對大多數的構造函數派生類(1.8),虛基類按順序初始化它們出現在有向的從左到右的深度優先遍歷中基類的非循環圖,其中從左到右"是派生類中基類的外觀基本說明符列表.

— 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.

——然后??,直接基類在出現在基本說明符列表中的聲明順序(不管內存初始化器的順序如何).

— Then, direct base classes are initialized in declaration order as they appear in the base-specifier-list (regardless of the order of the mem-initializers).

——然后??,非靜態數據成員按照它們在類定義(同樣不管內存初始化器).

— Then, non-static data members are initialized in the order they were declared in the class definition (again regardless of the order of the mem-initializers).

——最后,復合語句構造函數體被執行.

— Finally, the compound-statement of the constructor body is executed.

這篇關于是否在初始化變量之前調用了父類構造函數?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 久久精品色视频 | 久久久久国产精品 | 亚洲精品91 | 欧美一区二区大片 | 日韩av免费在线观看 | 日韩欧美国产不卡 | 亚洲国产精品久久久久秋霞不卡 | 天天天久久久 | 超碰电影 | 超碰精品在线 | 一区二区三区国产精品 | 在线观看免费国产 | 亚洲av毛片 | 黄色香蕉视频在线观看 | 国产中文在线 | 亚洲国产精品va在线看黑人 | 草草视频在线播放 | 亚洲一级黄色 | 中文字幕丁香5月 | 国产一区二区精品在线观看 | av影音| 日韩精品一区二区三区中文字幕 | av一区二区三区四区 | 综合久久亚洲 | www国产亚洲精品久久网站 | 翔田千里一区二区 | 国产午夜精品久久久久免费视高清 | 国产亚洲成av人片在线观看桃 | 香蕉二区| av中文在线播放 | 在线一区| 欧美亚洲综合久久 | 亚洲国产一区二区三区在线观看 | 国产精品麻 | 日本人做爰大片免费观看一老师 | 精品国产欧美一区二区三区成人 | 国产黄色小视频 | 日韩在线电影 | 久久精品久久精品 | 综合久久av | 国产精品美女久久久久aⅴ国产馆 |