One of the golden rules in C ++ is that the lifetime of an instance begins when its constructor completes successfully and ends when its destructor begins.
From this rule, we conclude that it is not recommended to call virtual methods in the constructor, since a possible derived instance is invalid, which will lead to undefined behavior.
The virtual constructor idiom mentioned in the C ++ FAQ 20.8 points to the opposite.
My question is:
I think you are mixing two separate (if vaguely related) things.
, , , ( , ). , Derived, Base, Base in Base; this Base::Base() Base *, , this. . , .
this
Base::Base()
Base *
. , § 12.7 2-3 ++ 03.
.
Source: https://habr.com/ru/post/1779719/More articles:we can make some changes to the object returned at runtime - javadrape and quit to reorder - jqueryWhat does this cycle do? - mathWhat happens with jQuery Masonry, when I click back in the browser, it lifts the user back? - javascriptотправка почты из php: заголовки интерпретируются как тело? - phpjavascript, which uses a function call like this (function () {// code;}) (); - javascriptThe base class in the initialization list of the constructor of the instance of the derived class (C ++) - c ++Create a new data type in JavaScript - javascriptFailed to start Intent service in my Android program, what's wrong? - androidAndroid background sensor data collector - androidAll Articles