I'm writing a library for my project, which interfaces sensors used and structures them in different systems.
But I'm such a noob at C++. The compiler is throwing this error:
libraries/cec-core/cec-core.cpp: In member function 'void Habitaculo::Update()':
libraries/cec-core/cec-core.cpp:15:8: error: expected unqualified-id before '.' token
_Sluz.Update();
This is the header of that class:
class Habitaculo
{
public:
Habitaculo(int refrate, int luzpin, int dhtpin);
//Values from Indoor Sensors
int temp;
int hum;
int luz;
//Update Methods
void Update(); //Updates sensors value
void UpdateReg(); //writes to SD or enabled output method
private:
//Clock Managing
long _PreviousMillis;
unsigned long _CurrentMillis;
int _RefreshRate;
//Sensor instances
class _Sluz;
class _SDHT;
};
This are the member functions affected:
Habitaculo::Habitaculo(int refrate, int luzpin, int dhtpin){
//Clock management
_RefreshRate = refrate;
_PreviousMillis = 0;
//Systems to initialize
LDR _Sluz(luzpin); //analogpin
DHT11 _SDHT(dhtpin); //buspin
}
void Habitaculo::Update(){
_CurrentMillis = millis();
if (_CurrentMillis-_PreviousMillis > _RefreshRate){
_Sluz.Update(); //unqualified-id before '.' token
_SDHT.Update(); //unqualified-id before '.' token
temp = _SDHT.temp; //expected primary-expression before '.'
hum = _SDHT.hum; //expected primary-expression before '.'
luz = _Sluz.value; //expected primary-expression before '.'
_PreviousMillis = _CurrentMillis;
}
}
The error is thrown in every step of the Update
method. But I can copy that piece of code right in the Habitaculo
constructor and it works well. So I assume I'm missing something basic about language syntax, because I'm really new to all this scene.
Every class involved in this (LDR, DHT11) works fine. It's when I try to put all this together into a new class - inside an unified Update method - that everything crashes.