title: Creating Die Class with Virtual Functions C++
body: <p>im trying to create a C++ program Die that contains a virtual roll function which simply returns the  a number between 1 and the number of sides. I have only started the program and i have come upon a n error which i have never seen nor do i understand it at all. I think its because i have not implemented the virtual function properly or it could be how i call the virtual function in the main class? but im not sure at all and i cant figure out the solution to the problem. </p>
  
  <p>Die.cpp</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  class Die{
      public:
          Die();
          Die(int numSide);
          virtual int roll();
          int rollTwoDice(Die d1, Die d2); 
  
      private:
          int side;
  };
  
  Die::Die():side(6){}
  
  Die::Die(int numSide):side(numSide){}
  
  int Die::roll(){
      return rand() % side + 1;
  }
  
  int Die::rollTwoDice(Die d1, Die d2){
      return d1.roll()+d2.roll();
  }
  </code></pre>
  
  <p>Main.cpp</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;time.h&gt;
  #include "Die.cpp"
  using namespace std;
  
  int main(){
  
      srand(time(NULL));  
  
      Die die();
      cout &lt;&lt; die.roll;
      cout &lt;&lt; die.roll;
      cout &lt;&lt; die.roll;
  }
  </code></pre>
  
  <p>And the error:</p>
  
  <pre><code>/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o: In function `_start':
  (.text+0x20): undefined reference to `main'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I compiled this using g++ Die.cpp -o Die on linux commandline.</p>