title: C++ Error C2653 'Class' is not a class or namespace name
body: <p>Good afternoon. I've started learning c++ and I am having and issue compiling my project.
  If you find some faulty code I would be glad if you tell me.</p>
  
  <p>I have the following definitions:</p>
  
  <p><strong>Utils.h</strong></p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;string&gt;
  using namespace std;
  
  class Utils
  {
  public:
  static string GetStringFromInt (int number);
  };
  </code></pre>
  
  <p><strong>Utils.cpp</strong></p>
  
  <pre><code>#include "Utils.h"
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  using namespace std;
  
   string Utils::GetStringFromInt (int number)
  {
  
      stringstream ss;
      ss &lt;&lt; number;
      return ss.str();
  }
  </code></pre>
  
  <p>and </p>
  
  <p><strong>Ping.h</strong></p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;string&gt;
  
  using namespace std;
  
  class Ping
  {
  public:
      static int PingIt(int argc, char* argv[],string &amp;mstime,string &amp;ttl);   
  };
  </code></pre>
  
  <p><strong>Ping.cpp</strong></p>
  
  <pre><code>#include "Ping.h"
  #include &lt;string&gt;
  #include "icmpdefs.h"
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;WinSock.h&gt;
  #include &lt;Windows.h&gt;
  #include "Utils.h"
  #pragma comment(lib,"wsock32.lib")
  using namespace std;
  
  int Ping::PingIt(int argc, char* argv[],string &amp;mstime,string &amp;ttl)
  {
  
  
      // Check for correct command-line args
      if (argc &lt; 2) {
          cerr &lt;&lt; "usage: ping &lt;host&gt;" &lt;&lt; endl;
          return 1;
      }
  
      // Load the ICMP.DLL
      HINSTANCE hIcmp = LoadLibrary("ICMP.DLL");
      if (hIcmp == 0) {
          cerr &lt;&lt; "Unable to locate ICMP.DLL!" &lt;&lt; endl;
          return 2;
      }
  
      // Look up an IP address for the given host name
      struct hostent* phe;
      if ((phe = gethostbyname(argv[1])) == 0) {
          cerr &lt;&lt; "Could not find IP address for " &lt;&lt; argv[1] &lt;&lt; endl;
          return 3;
      }
  
      // Get handles to the functions inside ICMP.DLL that we'll need
      typedef HANDLE (WINAPI* pfnHV)(VOID);
      typedef BOOL (WINAPI* pfnBH)(HANDLE);
      typedef DWORD (WINAPI* pfnDHDPWPipPDD)(HANDLE, DWORD, LPVOID, WORD,
              PIP_OPTION_INFORMATION, LPVOID, DWORD, DWORD); // evil, no?
      pfnHV pIcmpCreateFile;
      pfnBH pIcmpCloseHandle;
      pfnDHDPWPipPDD pIcmpSendEcho;
      pIcmpCreateFile = (pfnHV)GetProcAddress(hIcmp,
              "IcmpCreateFile");
      pIcmpCloseHandle = (pfnBH)GetProcAddress(hIcmp,
              "IcmpCloseHandle");
      pIcmpSendEcho = (pfnDHDPWPipPDD)GetProcAddress(hIcmp,
              "IcmpSendEcho");
      if ((pIcmpCreateFile == 0) || (pIcmpCloseHandle == 0) || 
              (pIcmpSendEcho == 0)) {
          cerr &lt;&lt; "Failed to get proc addr for function." &lt;&lt; endl;
          return 4;
      }
  
      // Open the ping service
      HANDLE hIP = pIcmpCreateFile();
      if (hIP == INVALID_HANDLE_VALUE) {
          cerr &lt;&lt; "Unable to open ping service." &lt;&lt; endl;
          return 5;
      }
  
      // Build ping packet
      char acPingBuffer[64];
      memset(acPingBuffer, '\xAA', sizeof(acPingBuffer));
      PIP_ECHO_REPLY pIpe = (PIP_ECHO_REPLY)GlobalAlloc(
              GMEM_FIXED | GMEM_ZEROINIT,
              sizeof(IP_ECHO_REPLY) + sizeof(acPingBuffer));
      if (pIpe == 0) {
          cerr &lt;&lt; "Failed to allocate global ping packet buffer." &lt;&lt; endl;
          return 6;
      }
      pIpe-&gt;Data = acPingBuffer;
      pIpe-&gt;DataSize = sizeof(acPingBuffer);      
  
      // Send the ping packet
      DWORD dwStatus = pIcmpSendEcho(hIP, *((DWORD*)phe-&gt;h_addr_list[0]), 
              acPingBuffer, sizeof(acPingBuffer), NULL, pIpe, 
              sizeof(IP_ECHO_REPLY) + sizeof(acPingBuffer), 5000);
      if (dwStatus != 0) {
          cout &lt;&lt; "Addr: " &lt;&lt;
                  int(LOBYTE(LOWORD(pIpe-&gt;Address))) &lt;&lt; "." &lt;&lt;
                  int(HIBYTE(LOWORD(pIpe-&gt;Address))) &lt;&lt; "." &lt;&lt;
                  int(LOBYTE(HIWORD(pIpe-&gt;Address))) &lt;&lt; "." &lt;&lt;
                  int(HIBYTE(HIWORD(pIpe-&gt;Address))) &lt;&lt; ", " &lt;&lt;
                  "RTT: " &lt;&lt; int(pIpe-&gt;RoundTripTime) &lt;&lt; "ms, " &lt;&lt;
                  "TTL: " &lt;&lt; int(pIpe-&gt;Options.Ttl) &lt;&lt; endl;
  
          mstime = Utils::GetStringFromInt((pIpe-&gt;RoundTripTime));
          ttl = Utils::GetStringFromInt(int(pIpe-&gt;Options.Ttl));
      }
      else {
          cerr &lt;&lt; "Error obtaining info from ping packet." &lt;&lt; endl;
      }
  
      // Shut down...
      GlobalFree(pIpe);
      FreeLibrary(hIcmp);
      return dwStatus;
  }
  </code></pre>
  
  <p>When I Compile the project I get:</p>
  
  <p><strong>Error 1   error C2653: 'Ping' : is not a class or namespace name  c:\users\clanderasm\documents\visual studio 2010\projects\landetestconsole\landecplusconsole\ping.cpp   14  1   LandeCplusConsole</strong></p>
  
  <p>I've read sometimes this error is thrown because you dont include "stdafx.h"
  on the first #include but I already changed it.</p>
  
  <p>If you could tell me something more I would be glad</p>