DHT does not name a type

Getting an error message when attempting to verify an Arduido sketch code. Don’t understand why I’m getting error.

the code is

#include <DHT.h>
#define dataPin 8 // Defines pin number to which the sensor is connected
DHT dht; // Creats a DHT object
void setup() {
  Serial.begin(9600);
}
void loop() {
  int readData = DHT.read22(dataPin); // Reads the data from the sensor
  float t = DHT.temperature; // Gets the values of the temperature
  float h = DHT.humidity; // Gets the values of the humidity
  
  // Printing the results on the serial monitor
  Serial.print("Temperature = ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print("    Humidity = ");
  Serial.print(h);
  Serial.println(" % ");
  
  delay(2000); // Delays 2 secods, as the DHT22 sampling rate is 0.5Hz
}

error message :

Arduino: 1.8.6 Hourly Build 2018/07/11 05:33 (Windows 10), Board: “Arduino/Genuino Uno”

dht11:3:5: error: no matching function for call to ‘DHT::DHT()’

DHT dht; // Creats a DHT object

^

In file included from D:\BAHAN PI\dht11\dht11\dht11.ino:1:0:

C:\Users\Hp\Documents\Arduino\libraries\DHT-sensor-library-master/DHT.h:41:4: note: candidate: DHT::DHT(uint8_t, uint8_t, uint8_t)

DHT(uint8_t pin, uint8_t type, uint8_t count=6);

^

C:\Users\Hp\Documents\Arduino\libraries\DHT-sensor-library-master/DHT.h:41:4: note: candidate expects 3 arguments, 0 provided

C:\Users\Hp\Documents\Arduino\libraries\DHT-sensor-library-master/DHT.h:39:7: note: candidate: constexpr DHT::DHT(const DHT&)

class DHT {

^

C:\Users\Hp\Documents\Arduino\libraries\DHT-sensor-library-master/DHT.h:39:7: note: candidate expects 1 argument, 0 provided

C:\Users\Hp\Documents\Arduino\libraries\DHT-sensor-library-master/DHT.h:39:7: note: candidate: constexpr DHT::DHT(DHT&&)

C:\Users\Hp\Documents\Arduino\libraries\DHT-sensor-library-master/DHT.h:39:7: note: candidate expects 1 argument, 0 provided

D:\BAHAN PI\dht11\dht11\dht11.ino: In function ‘void loop()’:

dht11:8:21: error: expected primary-expression before ‘.’ token

int readData = DHT.read22(dataPin); // Reads the data from the sensor

^

dht11:9:16: error: expected primary-expression before ‘.’ token

float t = DHT.temperature; // Gets the values of the temperature

^

dht11:10:16: error: expected primary-expression before ‘.’ token

float h = DHT.humidity; // Gets the values of the humidity

^

exit status 1
no matching function for call to ‘DHT::DHT()’

can anyone help?

The compiler tells you this :

DHT(uint8_t pin, uint8_t type, uint8_t count=6);

When you declare your DHT sensor, you need some arguments : the pin number and the type of sensor.

#define DHTPIN 2     // Digital pin connected to the DHT sensor
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);

The third argument is optionnal. It is even ignored in the latest version of the library...