title: Linker Error: Undefined reference / bad reloc address / ld returned 1 exit
body: <p>I am relatively new to programming especially object-oriented languages. I have class Player and am trying to use simple math functions in main to test. I noticed linker errors but ignored them until I got further in my function calling statements and now I'm a bit lost on where to look. I think I am misunderstanding overlapping constructors / constructors in general...</p>
  
  <h3>This is my error:</h3>
  
  <pre><code>*C:\Users\Nytza\AppData\Local\Temp\ccRUivW8.o   ootest.cpp:(.text+0x272): undefined reference to `Player::Player(char const*, int, int, int)'
  
  C:\Users\Nytza\AppData\Local\Temp\ccRUivW8.o    ootest.cpp:(.text+0x27e): undefined reference to `Player::Player()'
  
  C:\Users\Nytza\AppData\Local\Temp\ccRUivW8.o    ootest.cpp:(.text+0x2a5): undefined reference to `Player::Player(char const*, int, int, int)'
  
  C:\Users\Nytza\AppData\Local\Temp\ccRUivW8.o    ootest.cpp:(.text+0x2cc): undefined reference to `Player::Player(char const*, int, int, int)'
  
  C:\Users\Nytza\AppData\Local\Temp\ccRUivW8.o    ootest.cpp:(.text+0x2f6): undefined reference to `Player::Player(char const*, int, int, int)'
  
  C:\Users\Nytza\AppData\Local\Temp\ccRUivW8.o    ootest.cpp:(.text+0x320): undefined reference to `Player::Player(char const*, int, int, int)'
  
  c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe    C:\Users\Nytza\AppData\Local\Temp\ccRUivW8.o: bad reloc address 0x0 in section `.pdata$_ZStanSt13_Ios_FmtflagsS_'
  
  D:\Documents\Programs\collect2.exe  [Error] ld returned 1 exit status*
  </code></pre>
  
  <h2>includes / Player class</h2>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  using namespace std;
  
  class Player
  {
      public:
        Player();
        Player( const char [], int, int, int );
  
        void printPlayer();
        void printPlayer(const char[], int, int, int);
  
        void setName();
        void setName( const char [] );
        void changeGoals( int );
        void changeAssists( int );
        void changeRating( int );
  
        int getGoals();
        int getAssists();
        int getRating();
  
      private:
        char name[50];
        int goals;
        int assists;
        int rating;
  };
  </code></pre>
  
  <p>The errors start after adding these lines in main:</p>
  
  <h2>int main()</h2>
  
  <pre><code>int main()
  {
      Player p1 ("Nytza Delirosa", 1, 1, 1);
      Player p2;
      Player p3 ("Jonathan Toews", 10, 9, 6);
      Player p4 ("Patrick Kane", 11, 10, -3);
      Player p5 ("Brandon Saad", 5, 8, 8);
      Player p6 ("Andrew Shaw", 6, 5, 6);
  
  ...
      return 0;
  }
  </code></pre>
  
  <h2>All my functions:</h2>
  
  <pre><code>void Player::printPlayer()
  {   
      int points = getGoals() + getAssists();
      cout  &lt;&lt; name &lt;&lt; endl &lt;&lt;
          "Goals: " &lt;&lt; goals &lt;&lt;
          "Assists: " &lt;&lt; assists &lt;&lt;
          "Points: " &lt;&lt; points &lt;&lt;
          "Plus/Minus: " &lt;&lt; showpos &lt;&lt; rating &lt;&lt; noshowpos &lt;&lt; endl &lt;&lt; endl;
  }
  
  void Player::setName()
  {
      name[0] = '\0';
  }
  
  void Player::setName( const char playerName[] )
  {
      strcpy(name, playerName);
  }
  
  void Player::changeGoals( int goalsScored )
  {
      if (goalsScored &lt; 0 )
          cout &lt;&lt; "Error: Not at least 0 goals.";
      else goals++;
  }
  
  void Player::changeAssists( int assistsEarned )
  {
      if (assistsEarned &lt; 0 )
          cout &lt;&lt; "Error: Not at least 0 assists.";
      else assists=+assistsEarned;
  }
  
  int Player::getGoals()
  {
      return goals;
  }
  
  int Player::getAssists()
  {
      return assists;
  }
  
  int Player::getRating()
  {
      return rating;
  }
  </code></pre>