I am trying to develop an Arduino library that consists out of two classes. I want 'WayPointStack' to store an array of 'WPCommand', but I can't get it to work.
WayPointStack.h
#ifndef WayPointStack_h
#define WayPointStack_h
#include "Arduino.h"
#include "WPCommand.h"
class WayPointStack
{
public:
WayPointStack();
WayPointStack(WPCommand* wp);
WPCommand GetNextWP();
WPCommand GetWP(int i);
void AddWP(int target, int time);
int SetWPPointer(int i);
int GetLength();
private:
WPCommand* _wp;
int pointer;
int length;
};
#endif
WPCommand.h
#ifndef WPCommand_h
#define WPCommand_h
#include "Arduino.h"
class WPCommand
{
public:
WPCommand(int target, int time );
WPCommand();
int GetTarget();
int GetTime();
int LEFT;
int RIGHT;
int FORWARD;
int BACKWARD;
int STOP;
int END;
private:
int _target;
int _time;
};
#endif
Parts of WaypointStack.cpp
#include "Arduino.h"
#include "WayPointStack.h"
#include "WPCommand.h"
#define arrSize 100
WayPointStack::WayPointStack()
{
_wp = new WPCommand[arrSize]; // should be enough, heap blabla
length = 0;
pointer = 0;
}
WayPointStack::WayPointStack(WPCommand[] wp)
{
_wp = new WPCommand[arrSize]; // should be enough, heap blabla
for (int i = 0; i < sizeof(wp), i++){
_wp[i] = wp[i];
}
length = sizeof(wp);
pointer = 0;
}
I'm pretty sure I'm doing something wrong with the pointers, but I don't know how to fix it. The first two errors are
WayPointStack.cpp:24:42: error: expected ',' or '...' before 'wp'
WayPointStack::WayPointStack(WPCommand[] wp)
and
WayPointStack.cpp:27:29: error: 'wp' was not declared in this scope
for (int i = 0; i < sizeof(wp), i++){
I obviously have to use a pointer. This is all I know, so far. Has someone an idea?