Custom library question


i know more of c++ question, have difficulties writing library.

how construct in library?

here trying do.
rather rewriting encoder.h brilliant library want add options of own , make superclass (not sure you'd call it). can't seem construct myenc

interface.h

code: [select]

#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

code: [select]


#include "arduino.h"
#include "interface.h"
#include <encoder.h>

interface::interface ()
{

}

void interface::begin()
{
encoder myenc(2, 3);
}





one more little question (or hope) there way define size of array in constructor :

interface myinterface=interface(5);

where array of int of size 5 created i've searched web couple of hours , can't seem find answer. see people define constant , use define size of array… maybe way, lovely if wasn't.

thank much!

have @ how hardwareserial class inherit stream class

or better, this page :)

for second question, can allocate memory dynamically, it's not recommended because of problems create, see this page.


Arduino Forum > Using Arduino > Programming Questions > Custom library question


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code