title: Variable or Field 'nameOfVariable' declared void no idea why :(
body: <p>I've googled and searched on various websites and I can not work out why I get the follow errors from one of my functions.</p>
  
  <p><strong>error: variable or field 'ConnectClient' declared void</strong></p>
  
  <p><strong>error: 'Socket' was not declared in this scope</strong></p>
  
  <p>Both of those errors are for the line 38 of my code, which is the...</p>
  
  <pre><code>void ConnectClient(Socket _newConnection)
  </code></pre>
  
  <p>From what I understood from other posts asking about this question, it normally came down to inconsistencies with the header file (Which I'm NOT using for this little test) or they had a return type in the void function which I don't have.</p>
  
  <p>NOTE: I've removed extra bits of code that relate to part of the game code, and stacks of commented out code which I was testing.  This program is a little test into winsock use</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;winsock2.h&gt;
  
  using namespace std;
  const int serverPort = 31337;
  const int serverMaxClients = 10;
  SOCKET serverSocket;
  SOCKET clientSocketArray[serverMaxClients];   //should this have a -1 on it?
  
  bool clientSlotTaken[serverMaxClients];
  sockaddr clientSocketAddresses[serverMaxClients];
  
  int FindFreePlayerSpot()
  {
      for (int slotIndex = 0; slotIndex &lt; serverMaxClients; slotIndex++)
      {
          if (clientSlotTaken[slotIndex] == false)
          {
              return slotIndex;
          }
      }
      return -1;
  }
  
  void ConnectClient(Socket _newConnection)
  {
      int slotIndex = FindFreePlayerSpot();
      if (slotIndex == -1)
      {
          closesocket(_newConnection);
          cout &lt;&lt; "No player slots available, connection aborted"
      }
      else //Should have a connection
      {
          clientSocketArray[slotIndex] = _newConnection;
          if (clientSocketArray[slotIndex] == INVALID_SOCKET)
          {
              cout &lt;&lt; "Client Connection Error - INVALID SOCKET " &lt;&lt; WSAGetLastError();
          }
          else //Client should have connected
          {
              cout &lt;&lt; "Client Connected on socket slot [" &lt;&lt; slotIndex &lt;&lt; "] from " &lt;&lt; "\n";
              clientSlotTaken[slotIndex] = true;
          }
      }
  }
  
  void StartWinSock()
  {
      WSADATA WsaDat;
      if(WSAStartup(MAKEWORD(2,2),&amp;WsaDat)!=0)
      {
          std::cout&lt;&lt;"WSA Initialization failed!\r\n";
          WSACleanup();
          system("PAUSE");
      }
  
      serverSocket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
      if(serverSocket==INVALID_SOCKET)
      {
          std::cout&lt;&lt;"Server Socket creation failed.\r\n";
          WSACleanup();
          system("PAUSE");
      }
  
      SOCKADDR_IN serverInf;
      serverInf.sin_family=AF_INET;
      serverInf.sin_addr.s_addr=INADDR_ANY;
      serverInf.sin_port=htons(serverPort);
  
      if(bind(serverSocket,(SOCKADDR*)(&amp;serverInf),sizeof(serverInf))==SOCKET_ERROR)
      {
          std::cout&lt;&lt;"Unable to bind socket!\r\n";
          WSACleanup();
          system("PAUSE");
      }
  
      if(listen(serverSocket,SOMAXCONN)==SOCKET_ERROR)
      {
          std::cout&lt;&lt;"Unable to Listen!\r\n";
          WSACleanup();
          system("PAUSE");
      }
  
      u_long iMode=1;
      ioctlsocket(serverSocket,FIONBIO,&amp;iMode);
  }
  
  
  int main()
  {
      playerShip = new PlayerShip;
      bool runningServer = true;
  
          cout &lt;&lt; "Starting WinSock\n";
          StartWinSock();
          cout &lt;&lt; "Running on port " &lt;&lt; serverPort &lt;&lt; "\n";
  
  
          while (true)
          {
              //Check for a connection
              Socket newConnection = accept(serverSocket,NULL,NULL);
              if (newConnection != SOCKET_ERROR)
              {
                  cout &lt;&lt; "Incomming connection attempt";
                  ConnectClient(newConnection);
              }
              Sleep(1);
          }
  
  
      WSACleanup();
      return 0;
  }
  </code></pre>