I know this is probably more of a C++ question, but I have some difficulties writing a library.
How do I construct something in a library?
Here is what I am trying to do.
Rather than rewriting Encoder.h a brilliant library I want to add some options of my own and make a superclass (not sure that is what you'd call it). But i can't seem to construct myEnc
Interface.h
#ifndef Interface_h
#define Interface_h
#include "Arduino.h"
#include <Libraries/Encoder.h>
class Interface
{
public:
Interface();
void begin();
private:
Encoder myEnc;
};
#endif
Interface.cpp
#include "Arduino.h"
#include "Interface.h"
#include <Encoder.h>
Interface::Interface ()
{
}
void Interface::begin()
{
Encoder myEnc(2, 3);
}
one more little question (or so I hope) is there a way to define the size of an array in the constructor like so :
Interface myInterface=Interface(5);
where an array of int of size 5 would be created i've searched the web for a couple of hours and can't seem to find an answer. What I see most people do is define a constant and use that to define the size of an array… Maybe that is the only way, but it would be lovely if it wasn't.
Thank you very much!