[C++筆記] 建構函式的順序
Published in
1 min readOct 29, 2018
範例
class A
{
public:
A() : _n(1)
{
}
protected:
int _n;
};
class B : public A
{
public:
B() : _m(_n)
{
}
private:
int _m;
};
- 呼叫基底Class A,初始化_n為1
- 看Class B的初始清單,初始化_m為_n
- 執行Class B的主體