title: Just started C++: Undefined Symbol error on Compile
body: <p>Here's the situation:</p>
  
  <p>I just started my first C++ class. I know nothing about C++ and despite this being the an intro to C++ class, the teacher has taught pretty much NO syntax for the language, just logic that we already know.</p>
  
  <p>Now he gave us a program description and said, "write it, lol." I understand the logic fine, but as I said before, I know nothing about C++. Thus I wrote it first in java (which I do know), and then once I got it working in java, I tried to code it over to C++.</p>
  
  <p>However now I am getting the following error when I compile</p>
  
  <pre><code>uxb3% g++ -o Race race.cc
  Undefined                       first referenced
   symbol                             in file
  main                                /usr/local/gcc-4.1.1/bin/../lib/gcc/sparc-sun-solaris2.10/4.1.1/crt1.o
  ld: fatal: Symbol referencing errors. No output written to Race
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>Can someone please help me with this?</p>
  
  <p>Here is my code in a .txt file:
  <a href="http://rapidshare.com/files/195742284/race.txt.html" rel="nofollow noreferrer">http://rapidshare.com/files/195742284/race.txt.html</a></p>
  
  <p>and here it is in a copy paste:</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  class Race
  {
  
          void main()
          {
                  executeRace();
          }
  
          int randomMove()
          {
                  srand(time(NULL));
                  int randomInt = rand() % 100 + 1;
                  return randomInt;
          }
  
          void executeRace()
          {
                  int rabbitPosition = 1;
                  int turtlePosition = 1;
  
                  cout &lt;&lt; "BANG!!!" &lt;&lt; endl &lt;&lt; "AND THEY'RE OFF!!!";
  
                  while (rabbitPosition &lt;=70 &amp;&amp; turtlePosition &lt;=70)
                  {
                          printPositions(rabbitPosition, turtlePosition);
  
                          turtlePosition = turtleMoveSquares(turtlePosition);
                          rabbitPosition = rabbitMoveSquares(rabbitPosition);
                  }
  
                  printWinner(rabbitPosition, turtlePosition);
  
                  tie(rabbitPosition, turtlePosition);
          }
  
          int turtleMoveSquares(int tPosition)
          {
  
                  int turtleMove = randomMove();
  
                  if(turtleMove &gt;=1 &amp;&amp; turtleMove &lt;= 40)
                          tPosition = tPosition + 4;
  
                  if(turtleMove &gt;= 41 &amp;&amp; turtleMove &lt;= 50 )
                          tPosition = tPosition - 2;
  
                  if(turtleMove &gt;=51 &amp;&amp; turtleMove &lt;=100)
                          tPosition = tPosition + 2;
  
                  if(tPosition &lt; 1)
                          tPosition = 1;
  
                  return tPosition;
          }
  
  
          int rabbitMoveSquares(int rabbitPosition)
          {
  
                  int rabbitMove = randomMove();
  
                  if(rabbitMove &gt;=1 &amp;&amp; rabbitMove &lt;= 25)
                          rabbitPosition = rabbitPosition;
  
                  if(rabbitMove &gt;=26 &amp;&amp; rabbitMove &lt;= 55)
                          rabbitPosition = rabbitPosition + 10;
  
                  if(rabbitMove &gt;=56 &amp;&amp; rabbitMove &lt;=60)
                          rabbitPosition = rabbitPosition - 15;
  
                  if(rabbitMove &gt;=61 &amp;&amp; rabbitMove &lt;= 90)
                          rabbitPosition = rabbitPosition + 5;
  
                  if(rabbitMove &gt;=90 &amp;&amp; rabbitMove &lt;=100)
                          rabbitPosition = rabbitPosition - 3;
  
                  if(rabbitPosition &lt; 1)
                          rabbitPosition = 1;
  
                  return rabbitPosition;
          }
  
          void printPositions(int rabbitPositions, int turtlePositions)
          {
                  int turtleCount;
                  int rabbitCount;
                  int endCount;
  
                  if(rabbitPositions == turtlePositions &amp;&amp; rabbitPositions != 1)
                  {
                          turtleCount = 1;
  
                          while(turtleCount &lt; turtlePositions)
                          {
                                  cout &lt;&lt; "-";
                                  turtleCount = turtleCount+1;
                          }
                          cout &lt;&lt; "OUCH!";
                  }
  
                  else
                  {
                          turtleCount = 1;
                          rabbitCount = 1;
                          endCount=1;
  
                          if(turtlePositions &lt; rabbitPositions)
                          {
                                  while(turtleCount &lt; turtlePositions)
                                  {
                                          cout &lt;&lt;  "-";
                                                  turtleCount = turtleCount+1;
                                  }
  
                                  cout &lt;&lt; "T";
  
                                  while(rabbitCount &lt; (rabbitPositions - turtlePositions))
                                  {
                                          cout &lt;&lt;  "-";
                                          rabbitCount = rabbitCount+1;
                                  }
                                  cout &lt;&lt; "H";
  
                          }
  
                          if(rabbitPositions &lt; turtlePositions)
                          {
                                  while(rabbitCount &lt; rabbitPositions)
                                  {
                                          cout &lt;&lt; "-";
                                                  rabbitCount = rabbitCount+1;
                                  }
                                  cout &lt;&lt; "H";
  
                                  while(turtleCount &lt; (turtlePositions - rabbitPositions))
                                  {
                                          cout &lt;&lt; "-";
                                          turtleCount = turtleCount+1;
                                  }
                                  cout &lt;&lt; "T";
  
                                  cout &lt;&lt; "\n";
                          }
                  }
          }
  
          void printWinner(int rabbitPosition, int turtlePosition)
          {
                  if(turtlePosition &gt;= 70 &amp;&amp; rabbitPosition &lt; 70)
                  {
                          cout &lt;&lt; "TORTOISE WINS!!! YAY!!!\n";
                  }
                  else if(rabbitPosition &gt;=70 &amp;&amp; turtlePosition &lt; 70)
                  {
                          cout &lt;&lt; "Hare wins. Yuch.\n";
                  }
                  else if(rabbitPosition &gt;=70 &amp;&amp; turtlePosition &gt;=70)
                  {
                          cout &lt;&lt; "It's a tie\n";
                  }
          }
  
          void tie(int turtlePosition, int rabbitPosition)
          {
                  if(rabbitPosition &gt;=70 &amp;&amp; turtlePosition &gt;=70)
                          executeRace();
          }
  };
  </code></pre>