user6238: I have a decent level of programming skill, or at least I thought so. I've been getting an error when compiling this Ardulno sketch. I don't really know what this error means or how to fix it. What's wrong with my code that's causing these errors. I was in the middle of making a big change to my code, so a lot of it is commented out because I haven't gotten to those parts.
code:
#include <LinkedList.h>

const uint8_t PinLeft = 2;
const uint8_t PinMiddle = 3;
const uint8_t PinRight = 4;
const uint8_t PinLED = 13;

enum MouseButtons {LEFT, MIDDLE, RIGHT} ;

bool leftPressed = false;
bool middlePressed = false;
bool rightPressed = false;

void sendMouseState() {
    if (leftPressed == true && middlePressed == false && rightPressed == false) {
        Mouse.set_buttons(1, 0, 0);
    } else if (leftPressed == true && middlePressed == true && rightPressed == false) {
        Mouse.set_buttons(1, 1, 0);
    } else if (leftPressed == true && middlePressed == true && rightPressed == true) {
        Mouse.set_buttons(1, 1, 1);
    } else if (leftPressed == true && middlePressed == false && rightPressed == true) {
        Mouse.set_buttons(1, 0, 1);
    } else if (leftPressed == false && middlePressed == true && rightPressed == false) {
        Mouse.set_buttons(0, 1, 0);
    } else if (leftPressed == false && middlePressed == false && rightPressed == true) {
        Mouse.set_buttons(0, 0, 1);
    } else if (leftPressed == false && middlePressed == true && rightPressed == true) {
        Mouse.set_buttons(0, 1, 1);
    } else if (leftPressed == false && middlePressed == false && rightPressed == false) {
        Mouse.set_buttons(0, 0, 0);
    }
}

void mouseButtonPress(MouseButtons theButton);
void mouseButtonPress(MouseButtons theButton) {
    if (theButton == MouseButtons::LEFT) {
        leftPressed = true;
    } else if(theButton == MouseButtons::MIDDLE) {
        middlePressed = true;
    } else if (theButton == MouseButtons::RIGHT) {
        rightPressed = true;
    }
}

void mouseButtonRelease(MouseButtons button);
void mouseButtonRelease(MouseButtons button) {
    if (button == LEFT) {
        leftPressed = false;
    } else if(button == MIDDLE) {
        middlePressed = false;
    } else if (button == RIGHT) {
        rightPressed = false;
    }
}

volatile unsigned int nextPressLeft = 0;
volatile unsigned int nextPressCenter = 0;
volatile unsigned int nextPressRight = 0;
const int timeBetween = 150; //milliseconds

enum ActionType {KB, MOU}; //keyboard or mouse

class Action {
    public:
        uint16_t keyCode;
        ActionType actionType;

        Action (uint16_t keyCode, ActionType actionType) {
            this->keyCode = keyCode;
            this->actionType = actionType;
        }

};

class ModeAction {

    public:
        LinkedList<Action> *keys = new LinkedList<Action>();

        void addAction(Action action) {
            keys->add(action);
        }

};

class ActionManager {

    private:
        uint8_t modeL = 1;
        uint8_t modeM = 1;
        uint8_t modeR = 1;

        LinkedList<ModeAction> *lActions = new LinkedList<ModeAction>();
        LinkedList<ModeAction> *mActions=new LinkedList<ModeAction>();
        LinkedList<ModeAction> *rActions=new LinkedList<ModeAction>();

        bool lActing = false, mActing = false, rActing = false;

    public:
        ActionManager() {
            //actions for left switch
            //mode 1
            lActions->add(ModeAction());
            lActions->get(lActions->size() - 1).addAction(Action(MouseButtons.LEFT, ActionType.MOU));
            //mode 2
            lActions->add(ModeAction());
            lActions->get(lActions->size() - 1).addAction(Action(KEY_F11, ActionType.KB));
            //mode 3
            lActions->add(ModeAction());
            lActions->get(lActions->size() - 1).addAction(Action(KEY_LEFT_CTRL, ActionType.KB));
            lActions->get(lActions->size() - 1).addAction(Action(KEY_LEFT_ALT, ActionType.KB));
            //mode 4
            lActions->add(ModeAction());
            lActions->get(lActions->size() - 1).addAction(Action(KEY_W, ActionType.KB));

            //actions for middle switch
            //mode 1
            mActions->add(ModeAction());
            mActions->get(lActions->size() - 1).addAction(Action(MouseButtons.MIDDLE, ActionType.MOU));

            //actions for right switch
            //mode 1
            rActions->add(ModeAction());
            rActions->get(lActions->size() - 1).addAction(Action(MouseButtons.RIGHT, ActionType.MOU));

        }


        void cycleModeL() {
            this->modeL++;
            if(this->modeL >= lActions->size()) {
                this->modeL = 1;
            }
        }

        void cycleModeM() {
            this->modeM++;
            if(this->modeM >= mActions->size()) {
                this->modeM = 1;
            }
        }

        void cycleModeR() {
            this->modeR++;
            if(this->modeR >= rActions->size()) {
                this->modeR = 1;
            }
        }

    private:

        //void doDownActions(ModeAction modeActions, uint8_t mode) {
            //for (int i = 0; i < modeActions.at(mode).keys.length(); i++) {
                //if (modeActions[mode][i].keys[i].actionType == ActionType.KB) {
                    //Keyboard.press(modeActions[mode].keys[i].keyCode)
                //} else if (modeActions[mode].keys[i].actionType == ActionType.MOU) {
                    //mouseButtonPress(modeActions[mode].keys[i].keyCode);
                //}
            //}
            //sendMouseState();
        //}
//
        //void doUpActions(ModeAction modeActions, uint8_t mode) {
            //for (int i = 0; i < modeActions[mode].keys.length(); i++) {
                //if (modeActions[mode][i].keys[i].actionType == ActionType.KB) {
                    //Keyboard.release(modeActions[mode].keys[i].keyCode)
                //} else if (modeActions[mode].keys[i].actionType == ActionType.MOU) {
                    //mouseButtonRelease(modeActions[mode].keys[i].keyCode);
                //}
            //}
            //sendMouseState();
        //}

    public:

        //void leftDown() {
            //if (lActing == false) {
                //lActing = true;
                //doDownActions(lActions, modeL);
            //}
        //}
//
        //void middleDown() {
            //if (mActing == false) {
                //mActing = true;
                //doDownActions(mActions, modeM);
            //}
        //}
//
        //void rightDown() {
            //if (rActing == false) {
                //rActing = true;
                //doDownActions(rActions, modeR);
            //}
        //}
//
        //void leftUp() {
            //if (lActing == true) {
                //lActing = false;
                //doUpActions(lActions, modeL);
            //}
        //}
//
        //void middleUp() {
            //if (mActing == true) {
                //mActing = false;
                //doUpActions(mActions, modeM);
            //}
        //}
//
        //void rightUp() {
            //if (rActing == true) {
                //rActing = false;
                //doUpActions(rActions, modeR);
            //}
        //}

};

ActionManager actionManager = ActionManager();

void setup() {

    Serial.begin(115200);

    pinMode(PinLED, OUTPUT);

    //pinMode(PinRight, INPUT_PULLUP); // sets the digital pin as output
    //attachInterrupt(PinRight, isrChangeR, CHANGE); // interrrupt is data ready
//
    //pinMode(PinMiddle, INPUT_PULLUP); // sets the digital pin as output
    //attachInterrupt(PinMiddle, isrChangeM, CHANGE); // interrrupt is data ready
//
    //pinMode(PinLeft, INPUT_PULLUP); // sets the digital pin as output
    //attachInterrupt(PinLeft, isrChangeL, CHANGE); // interrrupt is data ready

}

void loop() {

    //if (Serial.available()) {
////change mode
        //mode = Serial.parseInt();
//
////release all buttons
        //Keyboard.releaseAll();
        //Mouse.set_buttons(0, 0, 0);
//
////turn off LED
        //digitalWrite(PinLED, LOW);
//
////flush the serial input buffer
        //while (Serial.available()) {
            //Serial.read();
        //}
//
    //}
    //delay(1000);
    //Serial.println("Running");
}

//void isrChangeL() {
    //cli();
    //if (digitalRead(PinLeft) == LOW && nextPressLeft < millis()) {
////Serial.println("Pressed");
        //digitalWrite(PinLED, HIGH); //set the LED on
//
        //if (mode == 0) {
            //Mouse.set_buttons(1, 0, 0);
        //} else if (mode == 1) {
            //Keyboard.press(KEY_F11);
        //} else if (mode == 2) {
            //Keyboard.press(KEY_LEFT_CTRL);
            //Keyboard.press(KEY_LEFT_ALT);
        //} else if (mode == 3) {
            //Keyboard.press(KEY_W);
        //}
//
        //nextPressLeft = millis() + timeBetween;
//
    //} else {
//// Serial.println("Released");
        //digitalWrite(PinLED, LOW); // set the LED off
//
        //if (mode == 0) {
            //Mouse.set_buttons(0, 0, 0);
        //} else if (mode == 1) {
            //Keyboard.release(KEY_F11);
        //} else if (mode == 2) {
            //Keyboard.release(KEY_LEFT_CTRL);
            //Keyboard.release(KEY_LEFT_ALT);
        //} else if (mode == 3) {
            //Keyboard.release(KEY_W);
        //}
//
        //nextPressLeft = millis() + timeBetween * 0.6;
//
//
    //}
    //sei();
//}
//
//void isrChangeM() {
    //cli();
////if (digitalRead(PinMiddle) == LOW && nextPressCenter < millis())
////{
////Keyboard.press(KEY_SPACE);
////delay(250);
////Keyboard.release(KEY_SPACE);
////}
//
    //if (digitalRead(PinMiddle) == LOW && nextPressCenter < millis()) {
////Serial.println("Pressed");
        //digitalWrite(PinLED, HIGH); //set the LED on
////Mouse.set_buttons(0, 1, 0);
//
        //nextPressCenter = millis() + timeBetween;
//
    //} else {
//// Serial.println("Released");
        //digitalWrite(PinLED, LOW); // set the LED off
////Mouse.set_buttons(0, 0, 0);
//
        //nextPressCenter = millis() + timeBetween * 0.6;
//
//
    //}
//
    //sei();
//}
//
//void isrChangeR() {
    //cli();
    //if (digitalRead(PinRight) == LOW && nextPressRight < millis()) {
////Serial.println("Pressed");
        //digitalWrite(PinLED, HIGH); // set the LED on
        //Mouse.set_buttons(0, 0, 1);
////Keyboard.press(KEY_F11);
        //nextPressRight = millis() + timeBetween;
    //} else {
//// Serial.println("Released");
        //digitalWrite(PinLED, LOW); // set the LED off
        //Mouse.set_buttons(0, 0, 0);
////Keyboard.release(KEY_F11);
        //nextPressRight = millis() + timeBetween * 0.6;
    //}
    //sei();
//}

compiler log:
Compiling debug version of 'click_switch_5_cycling' for 'Teensy LC'
click_switch_5_cycling.ino: In constructor ActionManager::ActionManager()

click_switch_5_cycling.ino: 106:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 106:66: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 106:83: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 109:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 109:73: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 112:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 112:79: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 113:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 113:78: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 116:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 116:71: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 121:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 121:66: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 121:85: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 126:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 126:66: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 126:84: error: expected primary-expression before '.' token

click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of bool LinkedList<T>::add(T) [with T = Action]
click_switch_5_cycling.ino:83: required from here

LinkedList.h: 192:37: error: use of deleted function 'ListNode<Action>::ListNode()
ListNode<T> *tmp = new ListNode<T>()
LinkedList.h:19: note  ListNode<Action>  ListNode() is implicitly deleted because the default definition would be ill-formed
struct ListNode

LinkedList.h: 19:8: error: no matching function for call to 'Action::Action()
click_switch_5_cycling.ino:70: note  candidate  Action  Action(uint16_t, ActionType)
this->actionType = actionType
click_switch_5_cycling.ino:70: note    candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(const Action&)
uint16_t keyCode
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(Action&&)
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided

click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of ListNode<T>* LinkedList<T>::getNode(int) [with T = ModeAction]
LinkedList.h:314: required from T LinkedList<T>  get(int) [with T = ModeAction]
click_switch_5_cycling.ino:106: required from here
LinkedList.h: 160:9: warning: converting 'false' to pointer type 'ListNode<ModeAction>*' [-Wconversion-null]
return false
LinkedList.h: In instantiation of bool LinkedList<T>::add(int, T) [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 177:37: error: use of deleted function 'ListNode<Action>::ListNode()
ListNode<T> *tmp = new ListNode<T>()
LinkedList.h: In instantiation of bool LinkedList<T>::unshift(T) [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 218:37: error: use of deleted function 'ListNode<Action>::ListNode()
ListNode<T> *tmp = new ListNode<T>()
LinkedList.h: In instantiation of T LinkedList<T>::remove(int) [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 290:12: error: no matching function for call to 'Action::Action()
return T()
click_switch_5_cycling.ino:70: note  candidate  Action  Action(uint16_t, ActionType)
this->actionType = actionType
click_switch_5_cycling.ino:70: note    candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(const Action&)
uint16_t keyCode
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(Action&&)
Error compiling project sources
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
Debug build failed for project 'click_switch_5_cycling'

click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of T LinkedList<T>::pop() [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 242:12: error: no matching function for call to 'Action::Action()
return T()
click_switch_5_cycling.ino:70: note  candidate  Action  Action(uint16_t, ActionType)
this->actionType = actionType
click_switch_5_cycling.ino:70: note    candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(const Action&)
uint16_t keyCode
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(Action&&)
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided

click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of T LinkedList<T>::shift() [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 268:12: error: no matching function for call to 'Action::Action()
return T()
click_switch_5_cycling.ino:70: note  candidate  Action  Action(uint16_t, ActionType)
this->actionType = actionType
click_switch_5_cycling.ino:70: note    candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(const Action&)
uint16_t keyCode
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(Action&&)
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided

click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of T LinkedList<T>::get(int) [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 316:14: error: no matching function for call to 'Action::Action()
T())
click_switch_5_cycling.ino:70: note  candidate  Action  Action(uint16_t, ActionType)
this->actionType = actionType
click_switch_5_cycling.ino:70: note    candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(const Action&)
uint16_t keyCode
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(Action&&)
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided

Thanks for any help you can give me about what these errors are and how to fix them.

user10794: The compiler is giving you a clue that the problem is around line 106. You have there:
  LinkedList<ModeAction> *lActions = new LinkedList<ModeAction>();
  LinkedList<ModeAction> *mActions=new LinkedList<ModeAction>();
  LinkedList<ModeAction> *rActions=new LinkedList<ModeAction>();

You can't do procedural code (like new) in a data declaration. Also, I doubt that there is a function to be called so I would get rid of the brackets. Initializing member fields should be done in the constructor, not in the declaration.

user22924: You seem to have been programming in Java recently, because many of your errors have a Java ‘whiff’ to them. This, as you’ve tagged, is C++, not Java.

sendMouseState:
a. You wrote leftPressed == true. This is much more simply expressed by the expression leftPressed.
b. You wrote middlePressed == false. This is much more simply expressed using the “not” operator !, as in !middlePressed.
c. The code tests all eight possible combinations of leftPressed, middlePressed and rightPressed, calling Mouse.set_buttons(#,#,#);
However, bools evaluate to numbers: false evaluates to 0, while true evaluates to 1. All eight tests, and therefore the entire function, can therefore be boiled down to the single line:
Mouse.set_buttons(leftPressed, middlePressed, rightPressed);
You declared to the compiler, in a few places, “There’s going to be a function called (e.g) void mouseButtonPress(MouseButtons theButton);”
That’s fair enough - but the compiler only needs that if you’re going to call the function before you define it. Since you follow the declarations immediately by the definitions, the declarations are unnecessary: get rid of them.
Use of enums:
Declaring an enum lets you use symbols instead of raw numbers: well done! However, that’s all you need to use: the enum’s symbol: LEFT, MIDDLE or RIGHT is all you need.
If you do feel the need to express the enum’s name, you need to use the :: operator, not the . operator: MouseButtons::LEFT.
Use of new:
You do not need to call new to create members of classes. Well, OK, you might if they’re declared as pointers (which you have done), but that’s your problem: you should declare them as simple members, not pointer members.
For example, instead of:
LinkedList<Action> *keys = new LinkedList<Action>();

you simply need:
LinkedList<Action> keys;

Note that no new is needed now. Then, everywhere that you dereference the member with keys->add(action);, you use keys.add(action); instead.
Use of this->:
You use this-> a lot. You practically never have to: however, the one time you did need to was in the code:
Action (uint16_t keyCode, ActionType actionType) {
    this->keyCode = keyCode;
    this->actionType = actionType;
}

Here, this-> was needed to distinguish the class members from the passed-in parameters that have the same name. However, if you’d written the constructor correctly, using initialisation instead of assignment, you wouldn’t have needed this-> here either:
Action (uint16_t keyCode, ActionType actionType) :
    keyCode(keyCode),
    actionType(actionType) {
}

add() followed by get():
You use the following code:
lActions.add(ModeAction());
lActions.get(lActions->size() - 1).addAction(Action(LEFT,MOU));

That is, you add an empty ModeAction, then fetch it back with get(...) before manipulating it. Don’t.
Instead, create a temporary ModeAction object, get it ready, then add() it to the list:
ModeAction lMode1;
lMode1.addAction(Action(LEFT,MOU));
lActions.add(lMode1);



6238: <p>I have a decent level of programming skill, or at least I thought so. I've been getting an error when compiling this Ardulno sketch. I don't really know what this error means or how to fix it. What's wrong with my code that's causing these errors. I was in the middle of making a big change to my code, so a lot of it is commented out because I haven't gotten to those parts.</p>

<p>code:</p>

<pre><code>#include &lt;LinkedList.h&gt;

const uint8_t PinLeft = 2;
const uint8_t PinMiddle = 3;
const uint8_t PinRight = 4;
const uint8_t PinLED = 13;

enum MouseButtons {LEFT, MIDDLE, RIGHT} ;

bool leftPressed = false;
bool middlePressed = false;
bool rightPressed = false;

void sendMouseState() {
    if (leftPressed == true &amp;&amp; middlePressed == false &amp;&amp; rightPressed == false) {
        Mouse.set_buttons(1, 0, 0);
    } else if (leftPressed == true &amp;&amp; middlePressed == true &amp;&amp; rightPressed == false) {
        Mouse.set_buttons(1, 1, 0);
    } else if (leftPressed == true &amp;&amp; middlePressed == true &amp;&amp; rightPressed == true) {
        Mouse.set_buttons(1, 1, 1);
    } else if (leftPressed == true &amp;&amp; middlePressed == false &amp;&amp; rightPressed == true) {
        Mouse.set_buttons(1, 0, 1);
    } else if (leftPressed == false &amp;&amp; middlePressed == true &amp;&amp; rightPressed == false) {
        Mouse.set_buttons(0, 1, 0);
    } else if (leftPressed == false &amp;&amp; middlePressed == false &amp;&amp; rightPressed == true) {
        Mouse.set_buttons(0, 0, 1);
    } else if (leftPressed == false &amp;&amp; middlePressed == true &amp;&amp; rightPressed == true) {
        Mouse.set_buttons(0, 1, 1);
    } else if (leftPressed == false &amp;&amp; middlePressed == false &amp;&amp; rightPressed == false) {
        Mouse.set_buttons(0, 0, 0);
    }
}

void mouseButtonPress(MouseButtons theButton);
void mouseButtonPress(MouseButtons theButton) {
    if (theButton == MouseButtons::LEFT) {
        leftPressed = true;
    } else if(theButton == MouseButtons::MIDDLE) {
        middlePressed = true;
    } else if (theButton == MouseButtons::RIGHT) {
        rightPressed = true;
    }
}

void mouseButtonRelease(MouseButtons button);
void mouseButtonRelease(MouseButtons button) {
    if (button == LEFT) {
        leftPressed = false;
    } else if(button == MIDDLE) {
        middlePressed = false;
    } else if (button == RIGHT) {
        rightPressed = false;
    }
}

volatile unsigned int nextPressLeft = 0;
volatile unsigned int nextPressCenter = 0;
volatile unsigned int nextPressRight = 0;
const int timeBetween = 150; //milliseconds

enum ActionType {KB, MOU}; //keyboard or mouse

class Action {
    public:
        uint16_t keyCode;
        ActionType actionType;

        Action (uint16_t keyCode, ActionType actionType) {
            this-&gt;keyCode = keyCode;
            this-&gt;actionType = actionType;
        }

};

class ModeAction {

    public:
        LinkedList&lt;Action&gt; *keys = new LinkedList&lt;Action&gt;();

        void addAction(Action action) {
            keys-&gt;add(action);
        }

};

class ActionManager {

    private:
        uint8_t modeL = 1;
        uint8_t modeM = 1;
        uint8_t modeR = 1;

        LinkedList&lt;ModeAction&gt; *lActions = new LinkedList&lt;ModeAction&gt;();
        LinkedList&lt;ModeAction&gt; *mActions=new LinkedList&lt;ModeAction&gt;();
        LinkedList&lt;ModeAction&gt; *rActions=new LinkedList&lt;ModeAction&gt;();

        bool lActing = false, mActing = false, rActing = false;

    public:
        ActionManager() {
            //actions for left switch
            //mode 1
            lActions-&gt;add(ModeAction());
            lActions-&gt;get(lActions-&gt;size() - 1).addAction(Action(MouseButtons.LEFT, ActionType.MOU));
            //mode 2
            lActions-&gt;add(ModeAction());
            lActions-&gt;get(lActions-&gt;size() - 1).addAction(Action(KEY_F11, ActionType.KB));
            //mode 3
            lActions-&gt;add(ModeAction());
            lActions-&gt;get(lActions-&gt;size() - 1).addAction(Action(KEY_LEFT_CTRL, ActionType.KB));
            lActions-&gt;get(lActions-&gt;size() - 1).addAction(Action(KEY_LEFT_ALT, ActionType.KB));
            //mode 4
            lActions-&gt;add(ModeAction());
            lActions-&gt;get(lActions-&gt;size() - 1).addAction(Action(KEY_W, ActionType.KB));

            //actions for middle switch
            //mode 1
            mActions-&gt;add(ModeAction());
            mActions-&gt;get(lActions-&gt;size() - 1).addAction(Action(MouseButtons.MIDDLE, ActionType.MOU));

            //actions for right switch
            //mode 1
            rActions-&gt;add(ModeAction());
            rActions-&gt;get(lActions-&gt;size() - 1).addAction(Action(MouseButtons.RIGHT, ActionType.MOU));

        }


        void cycleModeL() {
            this-&gt;modeL++;
            if(this-&gt;modeL &gt;= lActions-&gt;size()) {
                this-&gt;modeL = 1;
            }
        }

        void cycleModeM() {
            this-&gt;modeM++;
            if(this-&gt;modeM &gt;= mActions-&gt;size()) {
                this-&gt;modeM = 1;
            }
        }

        void cycleModeR() {
            this-&gt;modeR++;
            if(this-&gt;modeR &gt;= rActions-&gt;size()) {
                this-&gt;modeR = 1;
            }
        }

    private:

        //void doDownActions(ModeAction modeActions, uint8_t mode) {
            //for (int i = 0; i &lt; modeActions.at(mode).keys.length(); i++) {
                //if (modeActions[mode][i].keys[i].actionType == ActionType.KB) {
                    //Keyboard.press(modeActions[mode].keys[i].keyCode)
                //} else if (modeActions[mode].keys[i].actionType == ActionType.MOU) {
                    //mouseButtonPress(modeActions[mode].keys[i].keyCode);
                //}
            //}
            //sendMouseState();
        //}
//
        //void doUpActions(ModeAction modeActions, uint8_t mode) {
            //for (int i = 0; i &lt; modeActions[mode].keys.length(); i++) {
                //if (modeActions[mode][i].keys[i].actionType == ActionType.KB) {
                    //Keyboard.release(modeActions[mode].keys[i].keyCode)
                //} else if (modeActions[mode].keys[i].actionType == ActionType.MOU) {
                    //mouseButtonRelease(modeActions[mode].keys[i].keyCode);
                //}
            //}
            //sendMouseState();
        //}

    public:

        //void leftDown() {
            //if (lActing == false) {
                //lActing = true;
                //doDownActions(lActions, modeL);
            //}
        //}
//
        //void middleDown() {
            //if (mActing == false) {
                //mActing = true;
                //doDownActions(mActions, modeM);
            //}
        //}
//
        //void rightDown() {
            //if (rActing == false) {
                //rActing = true;
                //doDownActions(rActions, modeR);
            //}
        //}
//
        //void leftUp() {
            //if (lActing == true) {
                //lActing = false;
                //doUpActions(lActions, modeL);
            //}
        //}
//
        //void middleUp() {
            //if (mActing == true) {
                //mActing = false;
                //doUpActions(mActions, modeM);
            //}
        //}
//
        //void rightUp() {
            //if (rActing == true) {
                //rActing = false;
                //doUpActions(rActions, modeR);
            //}
        //}

};

ActionManager actionManager = ActionManager();

void setup() {

    Serial.begin(115200);

    pinMode(PinLED, OUTPUT);

    //pinMode(PinRight, INPUT_PULLUP); // sets the digital pin as output
    //attachInterrupt(PinRight, isrChangeR, CHANGE); // interrrupt is data ready
//
    //pinMode(PinMiddle, INPUT_PULLUP); // sets the digital pin as output
    //attachInterrupt(PinMiddle, isrChangeM, CHANGE); // interrrupt is data ready
//
    //pinMode(PinLeft, INPUT_PULLUP); // sets the digital pin as output
    //attachInterrupt(PinLeft, isrChangeL, CHANGE); // interrrupt is data ready

}

void loop() {

    //if (Serial.available()) {
////change mode
        //mode = Serial.parseInt();
//
////release all buttons
        //Keyboard.releaseAll();
        //Mouse.set_buttons(0, 0, 0);
//
////turn off LED
        //digitalWrite(PinLED, LOW);
//
////flush the serial input buffer
        //while (Serial.available()) {
            //Serial.read();
        //}
//
    //}
    //delay(1000);
    //Serial.println("Running");
}

//void isrChangeL() {
    //cli();
    //if (digitalRead(PinLeft) == LOW &amp;&amp; nextPressLeft &lt; millis()) {
////Serial.println("Pressed");
        //digitalWrite(PinLED, HIGH); //set the LED on
//
        //if (mode == 0) {
            //Mouse.set_buttons(1, 0, 0);
        //} else if (mode == 1) {
            //Keyboard.press(KEY_F11);
        //} else if (mode == 2) {
            //Keyboard.press(KEY_LEFT_CTRL);
            //Keyboard.press(KEY_LEFT_ALT);
        //} else if (mode == 3) {
            //Keyboard.press(KEY_W);
        //}
//
        //nextPressLeft = millis() + timeBetween;
//
    //} else {
//// Serial.println("Released");
        //digitalWrite(PinLED, LOW); // set the LED off
//
        //if (mode == 0) {
            //Mouse.set_buttons(0, 0, 0);
        //} else if (mode == 1) {
            //Keyboard.release(KEY_F11);
        //} else if (mode == 2) {
            //Keyboard.release(KEY_LEFT_CTRL);
            //Keyboard.release(KEY_LEFT_ALT);
        //} else if (mode == 3) {
            //Keyboard.release(KEY_W);
        //}
//
        //nextPressLeft = millis() + timeBetween * 0.6;
//
//
    //}
    //sei();
//}
//
//void isrChangeM() {
    //cli();
////if (digitalRead(PinMiddle) == LOW &amp;&amp; nextPressCenter &lt; millis())
////{
////Keyboard.press(KEY_SPACE);
////delay(250);
////Keyboard.release(KEY_SPACE);
////}
//
    //if (digitalRead(PinMiddle) == LOW &amp;&amp; nextPressCenter &lt; millis()) {
////Serial.println("Pressed");
        //digitalWrite(PinLED, HIGH); //set the LED on
////Mouse.set_buttons(0, 1, 0);
//
        //nextPressCenter = millis() + timeBetween;
//
    //} else {
//// Serial.println("Released");
        //digitalWrite(PinLED, LOW); // set the LED off
////Mouse.set_buttons(0, 0, 0);
//
        //nextPressCenter = millis() + timeBetween * 0.6;
//
//
    //}
//
    //sei();
//}
//
//void isrChangeR() {
    //cli();
    //if (digitalRead(PinRight) == LOW &amp;&amp; nextPressRight &lt; millis()) {
////Serial.println("Pressed");
        //digitalWrite(PinLED, HIGH); // set the LED on
        //Mouse.set_buttons(0, 0, 1);
////Keyboard.press(KEY_F11);
        //nextPressRight = millis() + timeBetween;
    //} else {
//// Serial.println("Released");
        //digitalWrite(PinLED, LOW); // set the LED off
        //Mouse.set_buttons(0, 0, 0);
////Keyboard.release(KEY_F11);
        //nextPressRight = millis() + timeBetween * 0.6;
    //}
    //sei();
//}
</code></pre>

<p>compiler log:</p>

<pre><code>Compiling debug version of 'click_switch_5_cycling' for 'Teensy LC'
click_switch_5_cycling.ino: In constructor ActionManager::ActionManager()

click_switch_5_cycling.ino: 106:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 106:66: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 106:83: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 109:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 109:73: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 112:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 112:79: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 113:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 113:78: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 116:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 116:71: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 121:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 121:66: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 121:85: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 126:53: error: expected primary-expression before '(' token

click_switch_5_cycling.ino: 126:66: error: expected primary-expression before '.' token

click_switch_5_cycling.ino: 126:84: error: expected primary-expression before '.' token

click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of bool LinkedList&lt;T&gt;::add(T) [with T = Action]
click_switch_5_cycling.ino:83: required from here

LinkedList.h: 192:37: error: use of deleted function 'ListNode&lt;Action&gt;::ListNode()
ListNode&lt;T&gt; *tmp = new ListNode&lt;T&gt;()
LinkedList.h:19: note  ListNode&lt;Action&gt;  ListNode() is implicitly deleted because the default definition would be ill-formed
struct ListNode

LinkedList.h: 19:8: error: no matching function for call to 'Action::Action()
click_switch_5_cycling.ino:70: note  candidate  Action  Action(uint16_t, ActionType)
this-&gt;actionType = actionType
click_switch_5_cycling.ino:70: note    candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(const Action&amp;)
uint16_t keyCode
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(Action&amp;&amp;)
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided

click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of ListNode&lt;T&gt;* LinkedList&lt;T&gt;::getNode(int) [with T = ModeAction]
LinkedList.h:314: required from T LinkedList&lt;T&gt;  get(int) [with T = ModeAction]
click_switch_5_cycling.ino:106: required from here
LinkedList.h: 160:9: warning: converting 'false' to pointer type 'ListNode&lt;ModeAction&gt;*' [-Wconversion-null]
return false
LinkedList.h: In instantiation of bool LinkedList&lt;T&gt;::add(int, T) [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 177:37: error: use of deleted function 'ListNode&lt;Action&gt;::ListNode()
ListNode&lt;T&gt; *tmp = new ListNode&lt;T&gt;()
LinkedList.h: In instantiation of bool LinkedList&lt;T&gt;::unshift(T) [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 218:37: error: use of deleted function 'ListNode&lt;Action&gt;::ListNode()
ListNode&lt;T&gt; *tmp = new ListNode&lt;T&gt;()
LinkedList.h: In instantiation of T LinkedList&lt;T&gt;::remove(int) [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 290:12: error: no matching function for call to 'Action::Action()
return T()
click_switch_5_cycling.ino:70: note  candidate  Action  Action(uint16_t, ActionType)
this-&gt;actionType = actionType
click_switch_5_cycling.ino:70: note    candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(const Action&amp;)
uint16_t keyCode
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(Action&amp;&amp;)
Error compiling project sources
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
Debug build failed for project 'click_switch_5_cycling'

click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of T LinkedList&lt;T&gt;::pop() [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 242:12: error: no matching function for call to 'Action::Action()
return T()
click_switch_5_cycling.ino:70: note  candidate  Action  Action(uint16_t, ActionType)
this-&gt;actionType = actionType
click_switch_5_cycling.ino:70: note    candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(const Action&amp;)
uint16_t keyCode
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(Action&amp;&amp;)
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided

click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of T LinkedList&lt;T&gt;::shift() [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 268:12: error: no matching function for call to 'Action::Action()
return T()
click_switch_5_cycling.ino:70: note  candidate  Action  Action(uint16_t, ActionType)
this-&gt;actionType = actionType
click_switch_5_cycling.ino:70: note    candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(const Action&amp;)
uint16_t keyCode
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(Action&amp;&amp;)
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided

click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of T LinkedList&lt;T&gt;::get(int) [with T = Action]
click_switch_5_cycling.ino:262: required from here

LinkedList.h: 316:14: error: no matching function for call to 'Action::Action()
T())
click_switch_5_cycling.ino:70: note  candidate  Action  Action(uint16_t, ActionType)
this-&gt;actionType = actionType
click_switch_5_cycling.ino:70: note    candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(const Action&amp;)
uint16_t keyCode
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note  candidate  constexpr Action  Action(Action&amp;&amp;)
click_switch_5_cycling.ino:65: note    candidate expects 1 argument, 0 provided
</code></pre>

<p>Thanks for any help you can give me about what these errors are and how to fix them.</p>
 10794: <p>The compiler is giving you a clue that the problem is around line 106. You have there:</p>

<pre><code>  LinkedList&lt;ModeAction&gt; *lActions = new LinkedList&lt;ModeAction&gt;();
  LinkedList&lt;ModeAction&gt; *mActions=new LinkedList&lt;ModeAction&gt;();
  LinkedList&lt;ModeAction&gt; *rActions=new LinkedList&lt;ModeAction&gt;();
</code></pre>

<p>You can't do procedural code (like <code>new</code>) in a data declaration. Also, I doubt that there is a function to be called so I would get rid of the brackets. Initializing member fields should be done in the constructor, not in the declaration.</p>
 22924: <p>You seem to have been programming in Java recently, because many of your errors have a Java ‘whiff’ to them. This, as you’ve tagged, is C++, not Java.</p>

<ol>
<li><p><code>sendMouseState</code>:</p>

<p>a. You wrote <code>leftPressed == true</code>. This is much more simply expressed by the expression <code>leftPressed</code>.</p>

<p>b. You wrote <code>middlePressed == false</code>. This is much more simply expressed using the “not” operator <code>!</code>, as in <code>!middlePressed</code>.</p>

<p>c. The code tests all eight possible combinations of <code>leftPressed</code>, <code>middlePressed</code> and <code>rightPressed</code>, calling <code>Mouse.set_buttons(#,#,#);</code></p>

<p>However, <code>bool</code>s evaluate to numbers: <code>false</code> evaluates to <code>0</code>, while <code>true</code> evaluates to <code>1</code>. All eight tests, and therefore the entire function, can therefore be boiled down to the single line:</p>

<p><code>Mouse.set_buttons(leftPressed, middlePressed, rightPressed);</code></p></li>
<li><p>You declared to the compiler, in a few places, “There’s going to be a function called (e.g) <code>void mouseButtonPress(MouseButtons theButton);</code>”</p>

<p>That’s fair enough - but the compiler only needs that if you’re going to <em>call</em> the function before you <em>define</em> it. Since you follow the declarations <em>immediately</em> by the definitions, the declarations are unnecessary: get rid of them.</p></li>
<li><p>Use of <code>enum</code>s:</p>

<p>Declaring an <code>enum</code> lets you use symbols instead of raw numbers: well done! However, that’s <em>all</em> you need to use: the <code>enum</code>’s symbol: <code>LEFT</code>, <code>MIDDLE</code> or <code>RIGHT</code> is all you need.</p>

<p>If you do feel the need to express the <code>enum</code>’s name, you need to use the <code>::</code> operator, not the <code>.</code> operator: <code>MouseButtons::LEFT</code>.</p></li>
<li><p>Use of <code>new</code>:</p>

<p>You do not need to call <code>new</code> to create members of classes. Well, OK, you might if they’re declared as pointers (which you have done), but that’s your problem: you should declare them as simple members, not pointer members.</p>

<p>For example, instead of:</p>

<pre><code>LinkedList&lt;Action&gt; *keys = new LinkedList&lt;Action&gt;();
</code></pre>

<p>you simply need:</p>

<pre><code>LinkedList&lt;Action&gt; keys;
</code></pre>

<p>Note that no <code>new</code> is needed now. Then, everywhere that you dereference the member with <code>keys-&gt;add(action);</code>, you use <code>keys.add(action);</code> instead.</p></li>
<li><p>Use of <code>this-&gt;</code>:</p>

<p>You use <code>this-&gt;</code> a lot. You practically never have to: however, the one time you did need to was in the code:</p>

<pre><code>Action (uint16_t keyCode, ActionType actionType) {
    this-&gt;keyCode = keyCode;
    this-&gt;actionType = actionType;
}
</code></pre>

<p>Here, <code>this-&gt;</code> was needed to distinguish the class members from the passed-in parameters that have the same name. However, if you’d written the constructor correctly, using initialisation instead of assignment, you wouldn’t have needed <code>this-&gt;</code> here either:</p>

<pre><code>Action (uint16_t keyCode, ActionType actionType) :
    keyCode(keyCode),
    actionType(actionType) {
}
</code></pre></li>
<li><p><code>add()</code> followed by <code>get()</code>:</p>

<p>You use the following code:</p>

<pre><code>lActions.add(ModeAction());
lActions.get(lActions-&gt;size() - 1).addAction(Action(LEFT,MOU));
</code></pre>

<p>That is, you add an empty <code>ModeAction</code>, then fetch it back with <code>get(...)</code> before manipulating it. Don’t.</p>

<p>Instead, create a temporary <code>ModeAction</code> object, get it ready, <em>then</em> <code>add()</code> it to the list:</p>

<pre><code>ModeAction lMode1;
lMode1.addAction(Action(LEFT,MOU));
lActions.add(lMode1);
</code></pre></li>
</ol>
