title: Error request for member getName which is of non-class type 'char'
body: <p>I'm trying to make a program involving files <code>assign2.cpp</code>, <code>Player.h</code>, <code>Player.cpp</code>, <code>Team.h</code>, <code>Team.cpp</code> which reads data from a txt file on player info (like hits, atBat, position, name and number) and displays it out into <code>assign2.cpp</code>. <code>assign2.cpp</code> is what contains <code>int main()</code> and is suppose to contain very little code because relies on the other files to do the work.</p>
  
  <p>The error:</p>
  
  <pre><code>request for member getName which is of non-class type ‘char’...
  </code></pre>
  
  <p>Please help, I've been trying to find the issue and can never do so. The compilation failure :</p>
  
  <pre><code>In file included from Team.cpp:1:0:
  Team.h:34:11: warning: extra tokens at end of #endif directive [enabled by default]
  Team.cpp: In constructor ‘Team::Team()’:
  Team.cpp:15:5: warning: unused variable ‘numPlayers’ [-Wunused-variable]
  Team.cpp: In member function ‘void Team::sortByName()’:
  Team.cpp:49:56: error: request for member ‘getName’ in ‘((Team*)this
  -&gt; Team::playerObject[(j + -1)]’, which is of non-class type ‘char’
  Team.cpp:49:74: error: request for member ‘getName’ in ‘bucket’, which is of non-class type ‘int’
  Team.cpp: In member function ‘void Team::print()’:
  Team.cpp:63:18: error: request for member ‘print’ in ‘((Team*)this)-                &gt;Team::playerObject[i]’, which is of non-class type ‘char’
  make: *** [Team.o] Error 1
  </code></pre>
  
  <p>Team.h</p>
  
  <pre><code>#ifndef TEAM_H
  #define TEAM_H
  #include "Player.h"
  
  class Team
  {
    private:
       char playerObject[40];
       int numPlayers; // specifies the number of Player objects
                       //   actually stored in the array
  
       void readPlayerData();
       void sortByName();
    public:
       Team();
       Team(char*);
  
       void print();
  };
  #endif / *Team.h*  /
  </code></pre>
  
  <p>Team.cpp</p>
  
  <pre><code>#include "Team.h"
  #include &lt;cstring&gt;
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;fstream&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  Team::Team()
  {
      strcpy (playerObject,"");
      int numPlayers = 0;
  }
  
  Team::Team(char* newPlayerObject)
  {
      strncpy(playerObject, newPlayerObject, 40);
  
      readPlayerData();
  }
  
  void Team::readPlayerData()
  {
      ifstream inFile;
  
      inFile.open("gamestats.txt");
      if (!inFile){
          cout &lt;&lt; "Error, couldn't open file";
          exit(1);
      }
  
      inFile.read((char*) this, sizeof(Team));
  
      inFile.close();
  }
  
  void Team::sortByName()
  {
      int i, j;
      int bucket;
  
      for (i = 1; i &lt; numPlayers; i++)
      {
          bucket = playerObject[i];
  
          for (j = i; (j &gt; 0) &amp;&amp; (strcmp(playerObject[j-1].getName(),   bucket.getName()) &gt; 0); j--)
              playerObject[j] = playerObject[j-1];
  
          playerObject[j] = bucket;
      }
  }
  </code></pre>
  
  <p>Player.h (incase anyone needs it)</p>
  
  <pre><code>#ifndef PLAYER_H
  #define PLAYER_H
  class Player
  {
      // Data members and method prototypes for the Player class go here
      private:
          int number;
          char name[26];
          char position[3];
          int hits;
          int atBats;
          double battingAverage;
  
      public:
          Player();
          Player(int, char*, char*, int, int);
          char* getName();
          char* getPosition();
          int getNumber();
          int getHits();
          int getAtBats();
          double getBattingAverage();
  
          void print();
          void setAtBats(int);
          void setHits(int);
  };
  #endif
  </code></pre>
  
  <p>I'm very stuck, Thanks in advance.</p>