title: How to add elements randomly into a vector using push_back
body: <p>As the Title states, I've been having trouble with adding random numbers as the elements into a vector of integer type. I included the time and stdlib libraries to work in conjunction with the vector library.</p>
  
  <p>My attempt(using classes) so far has been:</p>
  
  <p>To pass in a vector by reference into a function that adds random elements into a vector. In addition, passing a in reference to a variable I want to update, and using a pointer declared in the class and defined in the constructor to hold the memory address of the variable(same one that is was referenced to in previous lines).</p>
  
  <pre><code>class PlayerHand
  
  { 
       public:
             playerHand();
             void populateHand(vector&lt;int&gt;&amp;, int&amp;)
  
       private:
               vector&lt;int&gt; &amp;refVector; 
               int *pPointer;
               int giveCard;
   };
  
  playerHand::playerHand()
  
  {
     srand((time(NULL)));     
     giveCard = (rand() % 14) + 1;
  
     pPointer = &amp;giveCard;
  }
  
  
  void playerHand::populateHand(vector&lt;int&gt; &amp;refVector, int &amp;refGiveCard)
  
  { for( int i = 0; i &lt;= 8; i++)
  {
  
      refVector.push_back(*pPointer); //dereference thepointer to store value in giveCard
      srand(time(0));                      
      refGiveCard = (rand() %14) + 1;  /*Here is where I'm trying to update the reference
                                       so before the next loop, the reference should have
                                       a new updated value*/
  
      cout &lt;&lt; refVector.at(i) &lt;&lt; " ";
   }
   }
  </code></pre>
  
  <p>So after I compile the code, the elements in the vector are all the same number, and not different. What mistake in the code am I making?</p>