title: C++ Class Constructor With Array Member Variable
body: <p>I'm working on a problem where I'm to build a class with 40 integer array to calculate addition and subtraction on 40 digit numbers.</p>
  
  <p>I've written below code, but for some reason, it's keep failing with an error message:</p>
  
  <pre class="lang-none prettyprint-override"><code>Implicit instantiation of undefined template 'std::_1::array&lt;int, 40&gt;'.
  </code></pre>
  
  <p>I don't understand the error message and do not see any issue with the code. Could you please help?</p>
  
  <p>Also, as you can see, I'm using memcpy function, but when I just enter <code>std::memcpy( hugeInteger, integer, sizeof( integer ) )</code>, it spits out <code>No viable conversion from 'std::array&lt;int, 40&gt;' to 'void'.</code>
  As I understand, <code>memcpy</code> accepts pointer, and <code>hugeInteger</code> is a pointer to the first element of an array. Am I not understanding correctly?</p>
  
  <p>Below is the header:</p>
  
  <pre><code>#ifndef __Chapter_9__HugeInteger__
  #define __Chapter_9__HugeInteger__
  
  #include &lt;stdio.h&gt;
  #include &lt;vector&gt;
  
  class HugeInteger
  {
  public:
      explicit HugeInteger( bool = 1, std::array&lt; int, 40 &gt; = {} );
      void setHugeInteger( std::array&lt; int, 40 &gt; );
      void print();
  
  private:
      bool checkHugeInteger( std::array&lt; int, 40 &gt; );
  
      std::array&lt; int, 40 &gt; hugeInteger = {};
      bool sign;
  };
  
  #endif /* defined(__Chapter_9__HugeInteger__) */
  </code></pre>
  
  <p>Below is the cpp:</p>
  
  <pre><code>#include &lt;array&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;iostream&gt;
  #include "HugeInteger.h"
  
  HugeInteger::HugeInteger( bool sign, std::array&lt; int, 40 &gt; integer )
  : sign(sign)
  {
      setHugeInteger( integer );
  }
  
  void HugeInteger::setHugeInteger( std::array&lt; int, 40 &gt; integer )
  {
      if ( checkHugeInteger( integer ) )
          std::memcpy( hugeInteger, integer, sizeof( integer ) );
      else
          throw std::invalid_argument( "Single digit in the huge integer may not be negative ");
  }
  
  bool HugeInteger::checkHugeInteger( std::array&lt; int, 40 &gt; integer )
  {
      bool tester = 1;
  
      for ( int i = int( integer.size() ) - 1; i &gt;= 0; i-- )
      {
          if ( integer[i] &lt; 0 )
          {
              tester = 0;
              break;
          }
      }
  
      return tester;
  }
  
  void HugeInteger::print()
  {
      if ( sign &lt; 0 )
          std::cout &lt;&lt; "-";
  
      for( int i = int( hugeInteger.size() ) - 1; i &gt;= 0; i-- )
          std::cout &lt;&lt; hugeInteger[ i ];
  }
  </code></pre>