title: Random number vector's values set to 0 when placed inside other objects vector.
body: <p>Hi Having a problem where the &lt;<em>elemVec</em>> below gets emplaced in another vector of &lt;<em>ElementA</em>> objects, but the contents are all being set to 0. I have a debug line that's displaying the contents of &lt;<em>elemData</em>>, it clearly shows that values are being added to the vector.</p>
  
  <pre><code>#include "ElementA.h"
  #include &lt;iostream&gt;
  #include &lt;random&gt;
  #include &lt;ctime&gt;
  
  using std::cout;
  using std::endl;
  
  int main(int argc, char** argv)
  {
      vector&lt;ElementA&gt; elemVec;
      std::srand(time(NULL));
  
      //! Generate random sized vectors to populate elemVec.
      for (size numElems = 0; numElems &lt; 40; ++numElems) {
          //! Populate data for ElementA::mSolnSpace
          size vecSize = rand() % 10;
          vector&lt;size&gt; elemData;
          for (size i = 0; i &lt; vecSize; ++i) {
              elemData.push_back(i);
          }
  
          //! DEBUG: Output elemData.
          vector&lt;size&gt;::const_iterator it = elemData.cbegin();
          vector&lt;size&gt;::const_iterator end = elemData.cend();
          for (; it != end; ++it) {
              cout &lt;&lt; *it &lt;&lt; " ";
          }
          cout &lt;&lt; endl;
  
          //! Create the ElementA objects in the vector.
          size bID = rand() % 10;
          elemVec.emplace_back(ElementA(bID, elemData));
      }
  
  
      vector&lt;ElementA&gt;::const_iterator it = elemVec.cbegin();
      vector&lt;ElementA&gt;::const_iterator end = elemVec.cend();
      for (; it != end; ++it) {
          it-&gt;output();
          cout &lt;&lt; endl;
      }
  
  
      std::cin.get();
      return 0;
  }
  </code></pre>
  
  <p>and the ElementA class:</p>
  
  <pre><code>#ifndef ELEM_A_H
  #define ELEM_A_H
  
  #include &lt;vector&gt;
  #include &lt;iostream&gt;
  
  using std::vector;
  using std::cout;
  using std::endl;
  
  //! Shorthand specifications for common Data/Container types.
  typedef unsigned short int size;
  
  
  /*****************************************************************************\
  |                               Class Definitions                             |
  \*****************************************************************************/
  class ElementA
  {
  public:
      //! Constructor(s) &amp; Destructor:
      ElementA() = delete; //! Explicitly delete the default CTOR.
      ElementA(const size&amp; BlkID, const vector&lt;size&gt;&amp; Vec);
      ElementA(const ElementA&amp; src);
      virtual ~ElementA() {};
  
      //! View/Controller Method(s):
      size getID() const { return mBlkID; };
      size getSolnSize() const { return mSolnSize; };
      vector&lt;size&gt; getSoln() const { return mSolnSpace; };
      void removeSoln(const size&amp; value);
      void output() const;
  
      //! Overloaded Operator(s):
      friend bool operator&lt;(const ElementA&amp; lhs, const ElementA&amp; rhs);
  
  protected:
      //! Data:
      size mBlkID;
      size mSolnSize;
      vector&lt;size&gt; mSolnSpace;
  
  };
  
  
  /*****************************************************************************\
  |                                   Methods                                   |
  \*****************************************************************************/
  
  
  /************************************************************************/
  /*  Constructor:Parameter based: Initializes parameters                 */
  /*  Parameters: const size&amp; RID, const size&amp; CID, const size&amp; BID,      */
  /*              const vector&lt;size&gt;&amp; VEC)                                */
  /*  Auxiliary:  n/a                                                     */
  /*  Returns:    n/a                                                     */
  /*  Exceptions: n/a                                                     */
  /************************************************************************/
  ElementA::ElementA(const size&amp; BlkID, const vector&lt;size&gt;&amp; Vec) : mBlkID(BlkID), 
                                                                   mSolnSpace(Vec)
  {
      mSolnSize = Vec.size();
  }
  
  
  /************************************************************************/
  /*  Constructor:Performs copy construction using &lt;src&gt;.                 */
  /*  -- (Copy)                                                           */
  /*  Parameters: const ElementA&amp; src                                     */
  /*  Auxiliary:  n/a                                                     */
  /*  Returns:    n/a                                                     */
  /*  Exceptions: n/a                                                     */
  /************************************************************************/
  ElementA::ElementA(const ElementA&amp; src) : mBlkID(src.mBlkID), 
                          mSolnSize(src.mSolnSize), mSolnSpace(src.mSolnSize)
  {
  }
  
  
  
  /************************************************************************/
  /*  removeSoln: Updates the ElementA object by removing a number from   */
  /*              the Solution Space                                      */
  /*  Parameters: n/a                                                     */
  /*  Auxiliary:  n/a                                                     */
  /*  Returns:    n/a                                                     */
  /*  Exceptions: n/a                                                     */
  /************************************************************************/
  void ElementA::removeSoln(const size&amp; value)
  {
      vector&lt;size&gt;::iterator it = mSolnSpace.begin();
      vector&lt;size&gt;::iterator end = mSolnSpace.end();
  
      for (; it != end; ++it) {
          if (*it == value) {
              mSolnSpace.erase(it);
              --mSolnSize;
              break;
          }
      }
  
  }
  
  
  /************************************************************************/
  /*  operator&lt;:  Comparator tests whether &lt;lhs&gt; is strictly less than    */
  /*              &lt;rhs&gt;.                                                  */
  /*  Parameters: const ElementA&amp; lhs, const ElementA&amp; rhs                */
  /*  Auxiliary:  n/a                                                     */
  /*  Returns:    Boolean                                                 */
  /*  Exceptions: n/a                                                     */
  /************************************************************************/
  bool operator&lt;(const ElementA&amp; lhs, const ElementA&amp; rhs)
  {
      return lhs.mSolnSize &lt; rhs.mSolnSize;
  }
  
  
  /************************************************************************/
  /*  output:     Outputs the contents of &lt;this&gt; Element.                 */
  /*  Parameters: n/a                                                     */
  /*  Auxiliary:  n/a                                                     */
  /*  Returns:    n/a                                                     */
  /*  Exceptions: n/a                                                     */
  /************************************************************************/
  void ElementA::output() const
  {
      cout &lt;&lt; "BlockID: " &lt;&lt; mBlkID &lt;&lt; "\tSize: " &lt;&lt; mSolnSize &lt;&lt; "\t\tSoln: ";
  
      vector&lt;size&gt;::const_iterator it = mSolnSpace.cbegin();
      vector&lt;size&gt;::const_iterator end = mSolnSpace.cend();
  
      for (; it != end; ++it) {
          cout &lt;&lt; *it &lt;&lt; " ";
      }
      cout &lt;&lt; endl;
  }
  
  #endif
  </code></pre>
  
  <p>Really appreciate the time and help, thanks!</p>