user55227: 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?

user37622: This is a C++, not Arduino question and should be asked on Stack Overflow.
In C/C++ the [] must be on variable name, not on type. WPCommand wp[] (it is the same as WPCommand* wp). 
sizeof return size in bytes, not element count. send length as parameter
Dynamic memory allocation in MCU is not a good thing. You can have in WayPointStack
WPCommand _wp[arrSize] 


55227: <p>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.</p>

<p>WayPointStack.h</p>

<pre><code>#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
</code></pre>

<p>WPCommand.h</p>

<pre><code>#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
</code></pre>

<p>Parts of WaypointStack.cpp</p>

<pre><code>#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 &lt; sizeof(wp), i++){
        _wp[i] = wp[i];
    }
    length = sizeof(wp);
    pointer = 0;
}
</code></pre>

<p>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</p>

<pre><code>WayPointStack.cpp:24:42: error: expected ',' or '...' before 'wp'
WayPointStack::WayPointStack(WPCommand[] wp)
</code></pre>

<p>and</p>

<pre><code>WayPointStack.cpp:27:29: error: 'wp' was not declared in this scope
for (int i = 0; i &lt; sizeof(wp), i++){
</code></pre>

<p>I obviously have to use a pointer. This is all I know, so far.
Has someone an idea?</p>
 37622: <p>This is a C++, not Arduino question and should be asked on Stack Overflow.</p>

<p>In C/C++ the [] must be on variable name, not on type. <code>WPCommand wp[]</code> (it is the same as <code>WPCommand* wp</code>). </p>

<p><code>sizeof</code> return size in bytes, not element count. send <code>length</code> as parameter</p>

<p>Dynamic memory allocation in MCU is not a good thing. You can have in <code>WayPointStack</code></p>

<pre><code>WPCommand _wp[arrSize] 
</code></pre>
