i am sure this is a dumb question, but

what does this do?

DHT dht;

After you install the DHT library and #include it, that line creates an object of type DHT that is named 'dht'. The DHT object is defined in the library.

Basically the same as int i; or char ch; or …

so i notice in the sample code they use both. why caps and not caps. other than create confusion, what does this do?

void loop() {
DHT.read11(dht_apin);
Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(DHT.temperature);
Serial.println("C ");

sevenoutpinball:
so i notice in the sample code they use both. why caps and not caps. other than create confusion, what does this do?

void loop() {
DHT.read11(dht_apin);
Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(DHT.temperature);
Serial.println("C ");

They are mixing conventions. I think it's fair to use caps because the device is actually a DHT-11 not a dht-11. If you create a DHT object, I would personally recommend a more descriptive name than dht, like "dhtSensor".

I do this with some of my displays. instead of parroting the driver class name, I call it something like "display", if there is only one display in the system.

So, caps for the device, lower case for certain variables is that it?.

sevenoutpinball:
So, caps for the device...

No

the class defines the class name (and its appropriate spelling) so you have to exactly match how the library spells the class's constructor.

the name of the instance can be any valid C++ variable name.

in both cases the compiler is your friend and will give you a nice reminder that you made an error.

Something seems fishy here:

DHT dht;

void loop() {
  DHT.read11(dht_apin);
}

I don’t know which DHT library you’re using, but to me this implies that read11() is a Class Method, not an Instance Method. The Arduino DHT Library does have a read11() method, but it’s an Instance Method. And, the Class name is “dht” (lower case) not DHT.

The Adafruit DHT Library does have a Class name of DHT (upper case), but it does not have ANY method called “read11()”.

UPDATE:
Maybe you just got the instantiation wrong. Perhaps it should be:

dht DHT;

I still don't know what's a class and what is an object. is an included cpp always an object?

Also, this

The message has the following error or errors that must be corrected before continuing:
Unable to publish the post. Please notice you can only post once every 5 minutes and only edit posts after 30 seconds. Once you reach 100 published posts this limit will be removed.

is a real annoyance to getting anything done here. And by published posts do they include answers and replies or what?

An object is an instance of a class.

Going back to the earlier analogy, "char" or "int" are datatypes (analogous to class) but "int x;" defines a variable (instance) of type "int".

I don't know why some versions of the DHT libraries go against a fairly-well established convention, and call the class "dht" - it's perverse.

The five minute posting throttle is an invaluable tool preventing spam-bombing of the forum.

It also allows new users a little useful extra thinking time between posts, though not everyone makes best use of it.

the DHT is telling DHT.cpp, the star or the show in the adafruit library, to generate an instance of

dht

DHT invokes a program, dht is a name assigned to an instruction within that program. they have to have different names, or you just end up calling the program twice and not telling it what you want. lower case is a different name.

you could make it DHT humiditySensor1 if that suits you

the first DHT is necessary, the second dht is a choice made by a programmer.

A class is a template for creating objects.

An object is something that is constructed according to the specifications of the class.

Some classes erroneously assume there will only be one thing, and therefore have static methods and static state variables. This is always a design error. For example, one popular library for handling rotary encoders assumes at most one encoder. I need one for X, one for Y and one for Z. When you have a static method, you can call it as classname.method(), but a properly-designed library requires you to have an object, or a pointer to an object, and you call it as object.method() or objectpointer->method().

It is not "a name assigned to an instruction in that program" and the class is not a "program". This description is erroneous and confusing. The correct definition is that "it is the name of a method in the class". Methods that are static are unable to access the non-static member variables of the class; methods that are not static can access static and non-static members of the class.

class Something {
    protected:
       int count;
    public:
       Something() { count = 0; }
       void inc() { count++; }
       void dec() { count--; }
       bool isZero() { return count == 0; }
};

Something A;
Something B;

A.inc();
A.dec();
if(A.isZero())
    Serial.println("Working correctly: A");

B.inc();
B.inc();
if(B.isZero())
    Serial.println("Not working correctly: B");

Note that each of A and B have their own count variable. Note also that this is not very robust code; you should not be able to decrement below 0. Dealing with that is left as An Exercise For The Reader.

Some classes erroneously assume there will only be one thing, and therefore have static methods and static state variables. This is always a design error.

Nonsense. A class can be designed as a singleton, so that the "assumption" is guaranteed.

A class can have static methods and static fields, with appropriate non-static methods to manipulate the static data, so that the static methods do the right thing for the right instance.

Just because YOU have never done either one does NOT mean that it can't be done, or can't be done properly.

flounder:
Methods that are static are unable to access the non-static member variables of the class;

More nonsense.