문제

For example:

Class A
{
  A();
}

Class B
{
  A a;
  B(A& m_a) : a(m_a)
}

Which constructor will apply first? the A() constructor of the B parent, or the A object inside class B?

도움이 되었습니까?

해결책

If you are asking the order of the parent and derived class constructors, see Are parent class constructors called before initializing variables?.

In short, the base (or parent) class (looks like A in your case) constructor will complete first.

다른 팁

The parent constructor will execute first, then the subclass constructor will initialize the variable.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top