title: Returning int from object function call (basic)
body: <p>I've just started looking at C++ and I am having some problems I can't wrap my head around.</p>
  
  <p>I am trying to do something as simple as creating a class with a function, call that function and read the returned value.</p>
  
  <p>However I am stuck at what I guess is a minor issue.</p>
  
  <p>I know that it is the call from main to Die -> randomNumber that causes this error but I dont know why. I even tried to return the number 12 from the function without any luck.</p>
  
  <p><strong>Error:</strong>
  <a href="https://i.stack.imgur.com/64xs0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/64xs0.png" alt="error"></a></p>
  
  <p>I have 3 files (main.cpp, Die.h and Die.cpp)</p>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include &lt;string&gt;
  
  #include "Die.h"
  
  using namespace std;
  
  int main() {
      Die * test = new Die();
  
      cout &lt;&lt; std::to_string(test-&gt;randomNumber(4)) &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p><strong>Die.h</strong></p>
  
  <pre><code>#pragma once
  
  #include &lt;iostream&gt;
  #include &lt;ctime&gt;
  #include &lt;cstdlib&gt;
  
  class Die
  {
  public:
      Die();
      ~Die();
      void init();
      void rollDie(int&amp;, int&amp;);
      void rollDie(int*, int*);
      int randomNumber(int);
  
  };
  </code></pre>
  
  <p><strong>Die.cpp</strong></p>
  
  <pre><code>#include "Die.h"
  
  Die::Die()
  {
  }
  
  
  Die::~Die()
  {
  }
  
  void Die::init() {
  
  }
  
  int randomNumber(int max) {
      srand(static_cast&lt;unsigned int&gt;(time(0)));
      return (rand() % max + 1);
  }
  
  void rollDie(int&amp; die1, int&amp; die2) {
  
  }
  
  void rollDie(int* die1, int* die2) {
  
  }
  </code></pre>