user48730: I have a class named timeOut dealing with timeout tasks.
I'm to write a sketch, common for Sonoff basic and Sonoff Dual, meaning that I may have 1 task for Basic and 2 tasks for Dual.
Declaring instances looks like:
timeOUT timeOut_SW0("SW0",TIMEOUT_SW0);
timeOUT timeOut_SW0("SW1",TIMEOUT_SW1);

for code simplicity I'd rather create an array of references and call it using a for loop:
timeOUT TO[]={timeOut_SW0,timeOut_SW1};

is it the right way to call it as a reference ?

user7508: You can't. The C++ language doesn't support arrays of
references. You have the choice to either create an array of
objects:
timeOUT TO[] = {timeOUT("SW0",TIMEOUT_SW0), timeOUT("SW1",TIMEOUT_SW1);}

or an array of pointers:
timeOUT *TO[] = { &timeOut_SW0, &timeOut_SW1 };


48730: <p>I have a class named <code>timeOut</code> dealing with timeout tasks.</p>

<p>I'm to write a sketch, common for Sonoff basic and Sonoff Dual, meaning that I may have 1 task for Basic and 2 tasks for Dual.</p>

<p>Declaring instances looks like:</p>

<pre><code>timeOUT timeOut_SW0("SW0",TIMEOUT_SW0);
timeOUT timeOut_SW0("SW1",TIMEOUT_SW1);
</code></pre>

<p>for code simplicity I'd rather create an array of references and call it using a <code>for</code> loop:</p>

<pre><code>timeOUT TO[]={timeOut_SW0,timeOut_SW1};
</code></pre>

<p>is it the right way to call it as a reference ?</p>
 7508: <p>You can't. The C++ language <a href="https://stackoverflow.com/questions/1164266/why-are-arrays-of-references-illegal">doesn't support arrays of
references</a>. You have the choice to either create an array of
objects:</p>

<pre class="lang-cpp prettyprint-override"><code>timeOUT TO[] = {timeOUT("SW0",TIMEOUT_SW0), timeOUT("SW1",TIMEOUT_SW1);}
</code></pre>

<p>or an array of pointers:</p>

<pre class="lang-cpp prettyprint-override"><code>timeOUT *TO[] = { &amp;timeOut_SW0, &amp;timeOut_SW1 };
</code></pre>
