I'm a retired developer and now and have started Arduino programming and have some habits from OOP in my younger days.
I used NOT DIRECTLY to manipulate the properties of class but do it by use of get/set-methods.
When I do that here I get WARNINGS - look here:
warning: ISO C++ forbids declaration of 'setState' with no type [-fpermissive]
Here is my code for the setState-method:
LED_Controller::setState(int st) {
_state = st;
}
and here is the most of my header file:
class LED_Controller {
private:
byte _pin = 0;
int _state = 0;
unsigned long _lastChanged = 0;
unsigned long _timeToActivate = 0;
public:
LED_Controller(byte GPIO_pin,
int state,
unsigned long lastChng,
unsigned long timeToActi);
unsigned int getTimeToActivate();
unsigned int getLastChanged();
setLastChanged(unsigned int lc);
int getState();
setState(int st); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Here is the method !
byte getPin();
unsigned long toggleLED();
};
I have 2 questions to ask you PROs:
- What is "best practice" - to manipulate the properties DIRECTLY or by set/get-methods ?
- How do I get rid of these warnings ?