user31105: I know it is not a good practice to use the new command to dynamically create data, however, if I would never use the delete, would it result in memory gaps/other problems?
Background
The reason I need to create instances dynamically, is that I want to test my application first on a PC. And I want for several classes to have more properties for the PC version than for the Arduino version (for example, to store names, or information for the PC GUI to display). The PC version classes will be inherited from the Arduino (real) classes, but with added properties.
In some classes I need to build up a list, and I cannot use a type with hardcoded values to fill an array.
Example:
I have a LightSetup class that has a list of Pars (which are LED lights):
class LightSetup
{
protected:
    Par* _pars[NR_OF_PARS];

Par is the Arduino/real version, to fill in these I need:
LightSetup::LightSetup()
{
    for (int n = 0; n < NR_OF_PARS; n++)
    {
        _pars[n] = new Par(1 + 8 * n);
    }
}

In the PC version, instead of new Par, I use new TestPar. 
And in the header I cannot define it without a pointer like this:
    Par _pars[NR_OF_PARS];

Otherwise it cannot contain TestPar instances.

user4143: Sure. Using new or malloc to set things up initially is really no different to static allocations. There is nothing inherently bad with using malloc or new, only in using it repeatedly with free or delete.
Allocating a block of heap memory and keeping it allocated for the rest of eternity does not cause heap fragmentation. It's only repeated allocation and deallocation of variable sizes (such as String causes) that start to create problems. Allocating at the start of your program and leaving it allocated, as long as you don't allocate too much, of course, is not a problem.

user359: In the destructor you would need 
LightSetup::~LightSetup()
{
    for (int n = 0; n < NR_OF_PARS; n++)
    {
        delete _pars[n];
    }
}

and every time you replace a _pars you need to delete the old one. This can be done automatically by using unique_ptr.
However for your purpose it sounds like a #if is better suited to differentiate at compile time which type you actually store inside that array.
#if ON_ARDUINO
    Par _pars[NR_OF_PARS];
#else
    TestPar _pars[NR_OF_PARS];
#endif


31105: <p>I know it is not a good practice to use the <code>new</code> command to dynamically create data, however, if I would never use the <code>delete</code>, would it result in memory gaps/other problems?</p>

<p><strong>Background</strong></p>

<p>The reason I need to create instances dynamically, is that I want to test my application first on a PC. And I want for several classes to have more properties for the PC version than for the Arduino version (for example, to store names, or information for the PC GUI to display). The PC version classes will be inherited from the Arduino (real) classes, but with added properties.</p>

<p>In some classes I need to build up a list, and I cannot use a type with hardcoded values to fill an array.</p>

<p>Example:</p>

<p>I have a LightSetup class that has a list of Pars (which are LED lights):</p>

<pre><code>class LightSetup
{
protected:
    Par* _pars[NR_OF_PARS];
</code></pre>

<p>Par is the Arduino/real version, to fill in these I need:</p>

<pre><code>LightSetup::LightSetup()
{
    for (int n = 0; n &lt; NR_OF_PARS; n++)
    {
        _pars[n] = new Par(1 + 8 * n);
    }
}
</code></pre>

<p>In the PC version, instead of new Par, I use new TestPar. 
And in the header I cannot define it without a pointer like this:</p>

<pre><code>    Par _pars[NR_OF_PARS];
</code></pre>

<p>Otherwise it cannot contain TestPar instances.</p>
 4143: <p>Sure. Using <code>new</code> or <code>malloc</code> to set things up initially is really no different to static allocations. There is nothing inherently bad with using <code>malloc</code> or <code>new</code>, only in using it repeatedly with <code>free</code> or <code>delete</code>.</p>

<p>Allocating a block of heap memory and keeping it allocated for the rest of eternity does not cause heap fragmentation. It's only repeated allocation and deallocation of variable sizes (such as <code>String</code> causes) that start to create problems. Allocating at the start of your program and leaving it allocated, as long as you don't allocate <em>too much</em>, of course, is not a problem.</p>
 359: <p>In the destructor you would need </p>

<pre><code>LightSetup::~LightSetup()
{
    for (int n = 0; n &lt; NR_OF_PARS; n++)
    {
        delete _pars[n];
    }
}
</code></pre>

<p>and every time you replace a _pars you need to delete the old one. This can be done automatically by using unique_ptr.</p>

<p>However for your purpose it sounds like a <code>#if</code> is better suited to differentiate at compile time which type you actually store inside that array.</p>

<pre><code>#if ON_ARDUINO
    Par _pars[NR_OF_PARS];
#else
    TestPar _pars[NR_OF_PARS];
#endif
</code></pre>
