Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think Henning's answer is the way to go.<br> <code>*gDial</code> and <code>*gIP</code> in your code mean <code>gDial[0]</code> and <code>gIP[0]</code>.<br> So, you insert only the first element of the <code>KeyPair</code> array into <code>mMasterList</code>.</p> <p>Your <code>pressKeyPairs</code>'s declaration <code>template&lt;size_t nNumOfElements&gt; void pressKeyPairs(KeyPair(&amp;keys)[nNumOfElements]);</code> itself is correct. It takes a reference to <code>KeyPair</code> array as an argument.<br> However, since <code>mMasterList</code>'s <code>second_type</code> is <code>KeyPair</code>(not <code>KeyPair</code> array), <code>pressKeyPairs((*it).second)</code> invokes type mismatch error.</p> <p>How about the following ideas?</p> <ul> <li>Making a type <code>KeyPairArray</code> which points to <code>KeyPair</code> array</li> <li><code>pressKeyPairs</code> takes a reference to <code>KeyPairArray</code></li> </ul> <p>For example:</p> <pre><code>struct KeyPairArray { size_t nNumOfElements; KeyPair *keys; template&lt; size_t N &gt; KeyPairArray( KeyPair(&amp;k)[ N ] ) : nNumOfElements( N ), keys( k ) {} }; // Example void pressKeyPairs( KeyPairArray const&amp; keys ) { for ( size_t i = 0; i &lt; keys.nNumOfElements; ++ i ) { qDebug()&lt;&lt; keys.keys[ i ].qKey &lt;&lt;','&lt;&lt; keys.keys[ i ].strFormType &lt;&lt;'\n'; } } int main() { map&lt;string,KeyPairArray&gt; mMasterList; map&lt;string,KeyPairArray&gt;::iterator it; mMasterList.insert( make_pair( "Testing Test Menu", KeyPairArray( gDial ) ) ); for ( it=mMasterList.begin() ; it != mMasterList.end(); it++ ) { pressKeyPairs( it-&gt;second ); } } </code></pre> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload