I started out with a piece of code that both declares and initialises two objects from 3rd party libraries in one line (see below). That worked just fine.
#include <OneWire.h>
#include <DallasTemperature.h>
const int gpioPin = 0;
OneWire oneWire(gpioPin);
DallasTemperature sensors(&oneWire);
I then wanted to wrap it in a class and initialise oneWire
and sensors
when the class is initialised. So I came up with this:
#include <OneWire.h>
#include <DallasTemperature.h>
class TemperatureSensor
{
private:
OneWire oneWire;
DallasTemperature sensors;
public:
TemperatureSensor(int gpioPin);
};
TemperatureSensor::TemperatureSensor(int gpioPin)
{
oneWire(gpioPin);
sensors(&oneWire);
}
Which throws the error call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type
. So I guess I can't initialise an object like that when the declaration is already made. Any help is much appreciated.