title: Visual Studio 2015 C2011 'Class' type redefinition
body: <p>im currently working on a small console app, i read from some files, and i have made a simple animated loading bar thread to show the progress of file reading (sometimes the file are really huge)</p>
  
  <p>i have read on the microsoft documentation and on the forum and that error seems to suggest that i defined the class multiple time.</p>
  
  <p>but i did include all the header blocks to prevent this from happenning, any of you see my mistake, probly obvious, i havent done c++ in years.</p>
  
  <p>here is the code </p>
  
  <p>fileReader.h</p>
  
  <pre><code>#pragma once
  #ifndef FILEREADER_H // must be unique name in the project
  #define FILEREADER_H
  
  #include &lt;vector&gt;
  
  using namespace std;
  
  class fileReader {
  
  private:
  
  public:
      vector&lt;string&gt; readTextFile(string path);
      unsigned int getSize();
      unsigned int getLoadedBytes();
  };
  #endif      // FILEREADER_H
  #pragma once
  </code></pre>
  
  <p>fileReader.cpp</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;thread&gt;
  
  #include "numbers.h"
  #include "loadingBar.h"
  
  
  using namespace std;
  
  class fileReader {
  private:
  
  public :
      vector&lt;string&gt; list;
      int i;
      unsigned int size;
      unsigned int loadedBytes;
      string line;
      std::thread* barThread;
  
      vector&lt;string&gt; fileReader::readTextFile(string path) {
  
          ifstream file(path.c_str(), ios::in | ios::binary | ios::ate);
  
          i = 0;
          size = 0;
          loadedBytes = 0;
  
          ifstream file(path.c_str(), ios::in | ios::binary | ios::ate);
  
          if (file.is_open()) {
              size = file.tellg();
              cout &lt;&lt; "\t" &lt;&lt; path &lt;&lt; " (" &lt;&lt; formatNumbers(size) &lt;&lt; " bytes)" &lt;&lt; endl;
              file.clear();
              file.seekg(0, ios::beg);
  
              barThread = new std::thread(&amp;loadingBar::run, *this);
  
              while (file &gt;&gt; line) {
                  list.push_back(line);
                  loadedBytes += strlen(line.c_str());
                  i++;
              }
  
          }
          else {
              cout &lt;&lt; "Error reading : \"" &lt;&lt; path &lt;&lt; "\"" &lt;&lt; endl;
              exit(EXIT_FAILURE);
          }
          file.close();
          return list;
      }
  
      unsigned int fileReader::getSize() { return size; }
      unsigned int fileReader::getLoadedBytes() { return loadedBytes; }
  
  };
  </code></pre>
  
  <p>loadingBar.h</p>
  
  <pre><code>#pragma once
  #ifndef LOADINGBAR_H
  #define LOADINGBAR_H
  
  #include&lt;stdlib.h&gt;
  #include&lt;string&gt;
  #include&lt;iomanip&gt;
  #include "numbers.h"
  #include "fileReader.h"
  
  using namespace std;
  
  class loadingBar {
  public:
      void notififyFinish();
      void notifyError();
      void notifiError(string);
      void drawloadingBar();
      void drawPathBar();
      void drawBytesBar();
      void setLoadedUnits(int);
      void setTotalUnits(int);
      void run(fileReader*);
  
  };
  
  #endif // NUMBERS_H
  </code></pre>
  
  <p>loadingBar.cpp</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string&gt;
  #include &lt;iomanip&gt;
  
  #include "numbers.h"
  #include "fileReader.h"
  
  using namespace std;
  
  class loadingBar {
  
  private:
  
  public:
  
      double totalUnits = 1;
      double loadedUnits = 0;
      char loadedChar = '/';
      char emptyChar = ' ';
      int barLength = 50;
      double percent;
      int nbChar;
  
      void notiftyFinish() {
          cout &lt;&lt; " Ok" &lt;&lt; endl;
          //exit(EXIT_SUCCESS);
      }
  
      void notifiyError() {
          cout &lt;&lt; " Error !" &lt;&lt; endl;
          //exit(EXIT_FAILURE);
      }
  
      void notifiyError(string errMess) {
          cout &lt;&lt; " Error !" &lt;&lt; endl &lt;&lt; "\t" &lt;&lt; errMess;
          //exit(EXIT_FAILURE);
      }
  
      void drawLoadingBar() {
          cout &lt;&lt; fixed;
  
          cout &lt;&lt; "\rLoading [";
  
          for (int i = 0; i &lt; nbChar; i++)
              cout &lt;&lt; loadedChar;
  
          for (int i = nbChar; i &lt; barLength - 1; i++)
              cout &lt;&lt; emptyChar;
  
          cout &lt;&lt; "] " &lt;&lt; setprecision(0) &lt;&lt; percent &lt;&lt; "%";
      }
  
      void drawPathBar(string path) {
          cout &lt;&lt; fixed;
  
          cout &lt;&lt; "\rLoading [ ";
  
          cout &lt;&lt; path;
  
          cout &lt;&lt; " ] " &lt;&lt; setprecision(0) &lt;&lt; percent &lt;&lt; "%";
      }
  
      void drawBytesBar() {
          cout &lt;&lt; fixed;
  
          cout &lt;&lt; "\rLoading [ ";
  
          cout &lt;&lt; formatNumbers(loadedUnits) &lt;&lt; " / " &lt;&lt; formatNumbers(totalUnits);
  
          cout &lt;&lt; " ] " &lt;&lt; setprecision(0) &lt;&lt; percent &lt;&lt; "%";
      }
  
      void setLoadedUnits(int newValue) {
          if (newValue &gt; 0)
              loadedUnits = newValue;
      }
  
      void setTotalUnits(int value) {
          if (value &gt; 0)
              totalUnits = value;
      }
  
      void run(fileReader *f) {
          setTotalUnits(f-&gt;getSize());
          setLoadedUnits(f-&gt;getLoadedBytes());
  
          while (loadedUnits &lt;= totalUnits) {
              setLoadedUnits(f-&gt;getLoadedBytes());
              percent = ((double)(loadedUnits / totalUnits) * 100);
              nbChar = (int)(percent / (int)(100 / barLength));
  
              drawLoadingBar();
  
              //setLoadedUnits((int)loadedUnits + 10);
  
              if (loadedUnits &gt;= totalUnits) notiftyFinish();
          }
      }
  };
  </code></pre>