Use libraries within a class

I am trying to find a way to use a library within a class, as a class variable like:

#include <OneWire.h>
#include <DallasTemperature.h>


class TemperatureSensor {
  //local variables
  OneWire oneWire_(5);
  DallasTemperature dallasSensors_;
  
  public:
    // Constructor method.
    TemperatureSensor(){
      // do stuff
    };  
    // Methods to detect the temperature.
    float getCurrentTemperature(void){};
    float getLastTemperature(void){};
};

But it does not compile.

How can i do it?

Post an MCVE.
Post complete error messages (in code tags).

I've written a wrapper for the DallasTemperature library if you want to take a look:

gfvalvo:
I’ve written a wrapper for the DallasTemperature library if you want to take a look:
https://github.com/gfvalvo/nonBlockingDS18B20

Cool. I will definitely have a look at your library.

I have a non blocking HX711 library you might like. :wink:

Thanks.
I actually had to write non-blocking HX711 code a couple months back for my Kegerator Monitor project.