After searching through google and not being able to fix the problem, I decided to ask here.
So I am trying to implement inheritance, but unfortunately I am getting compiler error:
Code:
ControllerJoystickMode.h:7:1: error: expected class-name before '{' token
I read on stackoverflow: "That sort of error is usually caused by the type not being defined when you try to use it."
So I tried to forward declare classes by adding
Code:
class JoystickMode;
in ControllerJoystickMode.h
, and
Code:
class ControllerJoystickMode;
, in JoystickMode.h
, but that didn't help either.
JoystickMode.h
Code:
#ifndef _JOYSTICK_MODE_H_
#define _JOYSTICK_MODE_H_
#include "Joystick.h"
#include "Arduino.h"
class JoysticMode
{
public:
virtual String toString(void) = 0;
virtual void handle(void) = 0;
};
#endif
ControllerJoystickMode.h
Code:
#ifndef _CONTROLLER_JOYSTICK_MODE_H_
#define _CONTROLLER_JOYSTICK_MODE_H_
#include "JoystickMode.h"
class ControllerJoystickMode : public JoystickMode
{
public:
String toString(void);
};
#endif