Looks like you're trying to write the implementation of this constructor? DHT::DHT(int pin, EventGroupHandle_t evgrp, int event_bit, constchar* TaskName, TickType_t cycle_ms )
Looks like you want the constructor to call a class member function, setup.
what is the line of thinking when creating a class without specifying a constructor?
The line of thinking is "I want to create an object and the constructor doesn't need any parameters, I can just use the default constructor". It's pretty normal and common.
It is bad object, bad C++, to have a class that needs the programmer to call an extra member function on it just to put it into a good state. If that member function MUST always be called, that it should be called in the constructor.
DHT class doesn't seem to have a constructor.
This is a constructor: DHT(int pin, EventGroupHandle_t evgrp, int time_bit, constchar* TaskName, TickType_t cycle_ms = 10000 );
Edit: Oh, you've edited the original post and changed your original question, rendering the answers nonsensical. Please don't do that. It renders the thread nonsensical.
Now you're just calling the function wrong.
1 2
DHT::DHT(int pin, EventGroupHandle_t evgrp, int event_bit, constchar* TaskName, TickType_t cycle_ms ) {
DHTesp.setup(pin,DHTesp::DHT11) ; // This is NOT how to call a member function.
I already wrote the code that showed you how to call a member funciton. I already wrote the code that calls the setup function inside the constructor. What happens if, instead of doing it wrong, you write the code as I showed you?
Repeater,
thank you very much. _all_ your questions make perfect sense to me. If I did mess up the original post - my apologies. But as of right now - all answers make perfect sense to me.
I see now, that my copy from example ("dht") and copy from my code ("DHT") possibly create confusion.
... I already wrote the code that showed you how to call a member function. I already wrote the code that calls the setup function inside the constructor. What happens if, instead of doing it wrong, you write the code as I showed you?