virtual inheritance and constructor

Hi, I'm learning arduino c++ and got a Problem with following code:

//===============================================================
//  (base class)    
//===============================================================
class T_Sens_Base {
  public:
    bool    has_init;

    T_Sens_Base()
    {
      _out( "T_Sens_Base:: ()");
      _init();
    }
    void  _init()
    {
      _out( "T_Sens_Base::_init()");
      has_init= setup_init();
    }

    virtual bool  setup_init()
    {
      _out( "T_Sens_Base::setup_init()");
      return false;
    }
};


//===============================================================
//      DHT 22
//===============================================================

DHT dht(DHTPIN, DHTTYPE);

class TData_DHT22 : public T_Sens_Base {
  public:
    TData_DHT22():T_Sens_Base()
    { 
      _out( "TData_DHT22:: ()");
      _init();
    };

    virtual bool  setup_init()
    {
      _out( "TData_DHT22::setup_init()");
      dht.begin();
      return true;
    }
};

//===============================================================
(and later somewhere:   
T_Sens_Base *DHT_22; DHT_22 = new TData_DHT22();
)
//===============================================================

the log shows:

T_Sens_Base:: ()
T_Sens_Base::_init()
T_Sens_Base::setup_init()
TData_DHT22:: ()
T_Sens_Base::_init()
TData_DHT22::setup_init()

Please, why is the virtual function "T_Sens_Base::_init()" of the base class called instead of the overwritten "TData_DHT22::setup_init()" in Constructor of T_Sens_Base ?

the code seems to be correct because a later call of
DHT_22->_init()
also calls the overwritten function "TData_DHT22::setup_init()" and not that one of the base class.

Please can somebody help me? Thank's in advance.

We have a problem with the code and error messages unless they really do contain smileys

Please see Read this before posting a programming question and follow the advice on how to post code

When you create an object of the derived type, first the base constructor is called, and then the derived constructor is called.

This means that while the base constructor executes, the derived object has not been constructed yet!
It would be pointless (and probably undefined behavior) to call any of its methods before the object exists.
That's why the virtual function mechanism is disabled during execution of the base class.
https://isocpp.org/wiki/faq/strange-inheritance

_Also, _what's _up _with _all _those _underscores?

Pieter

thank you very much for your helpful answers, now it's clear.

@Pieter: your question about the underscores - sry, sometime ago I began to mark all internal (and helper-) functions to start with underscore and the "important" without; better reading for me, nothing else.

oldjoe:
@Pieter: your question about the underscores - sry, sometime ago I began to mark all internal (and helper-) functions to start with underscore and the "important" without; better reading for me, nothing else.

You can make helper functions private or protected if they're member functions, or add them in an anonymous namespace in the implementation file if they're free functions.

Keep in mind that using a leading underscore followed by a capital letter is not allowed and may invoke undefined behavior.

Thank you very much for that ("leading underscore followed by a capital letter ..."), PeterP - important to know for me - I will change my codes.

(SCO-Unix with C had been decades ago and since then I have working in Lazarus and Delphi; now restarting with c++; never heard about such restrictions with underscore. But I'm hungry for such infos to make my code better. Thank you very much.)

PieterP:
Keep in mind that using a leading underscore followed by a capital letter is not allowed and may invoke undefined behavior.

???

Juraj:
???

Granted, that undefined behavior will probably be a cryptic compilation error, if anything, but still, it's not allowed.