Is there a way to automatically call a particular method immediately after all constructors have run?

前端 未结 4 1886
独厮守ぢ
独厮守ぢ 2021-02-12 12:54

I want to be able to call a particular method automatically upon construction of a derived object, however I can\'t think how to do it. The following code illustrates. Another a

4条回答
  •  爱一瞬间的悲伤
    2021-02-12 13:17

    Based on your example you are accomplishing ACB, you want to accomplish ABC.

    In order to run code after the child constructor, you need to make the call after B (the child constructor) you cannot call the code at A (the parent constructor) then you won't accomplish ABC.

    Move DoThisAutomaticallyAfterConstruction() at the end of the child class constructor?

    Truly a strange question though.

提交回复
热议问题