title: c++ operator is ambiguous and other
body: <p>Hi I have this c++ project which gets me some weird error which I have no idea how to fix. So if someone can give me a solution, that would be great.</p>
  
  <pre><code>    #include &lt;iostream&gt;
      #include &lt;string&gt;
      #include &lt;fstream&gt;
      #include &lt;vector&gt;
      #include &lt;algorithm&gt;
      #include &lt;iomanip&gt;
  
      using namespace std;
      using std::ostream;
      using std::endl;
      using std::cout; 
  
      class CStudentEmploy
      {
      private:
          string m_strName;
          string m_strFacNum;
          int m_iMinutes;
  
      public:
  
          CStudentEmploy(int m = 0) // Podrazbirasht se konstruktor 
          {
              m_strName = "N/A";
              m_strFacNum = "N/A";
              m_iMinutes = m;
          }
  
          CStudentEmploy(string n, string f, int m) // Ekspliciten konstruktor
          {
              m_strName = n;
              m_strFacNum = f;
              m_iMinutes = m;
          }
  
          CStudentEmploy(const CStudentEmploy &amp;obj) // Copy konstruktor 
          {
              m_strName = obj.m_strName;
              m_strFacNum = obj.m_strFacNum;
              m_iMinutes = obj.m_iMinutes;
          }
  
          string GetName()
          {
              return m_strName;
          }
  
          string GetFacNum()
          {
              return m_strFacNum;
          }
  
          int GetMinutes()
          {
              return m_iMinutes;
          }
  
          void SetName (string n)
          {
              m_strName = n;
          }
          void SetFacNum (string f)
          {
              m_strFacNum = f;
          }
          void SetMinutes (int m)
          {
              m_iMinutes = m;
          }
  
          CStudentEmploy operator =(CStudentEmploy obj)
          {
              m_strName = obj.m_strName;
              m_strFacNum = obj.m_strFacNum;
              m_iMinutes = obj.m_iMinutes;
              return *this;
          }
  
  
          bool operator &lt; (const CStudentEmploy&amp; obj) const
          {
              return m_iMinutes &lt; obj.m_iMinutes;
          }
  
          CStudentEmploy operator +(const CStudentEmploy &amp;obj) const
          {
              return CStudentEmploy(m_iMinutes + obj.m_iMinutes);
          }
  
          friend ostream&amp; operator &lt;&lt;(ostream&amp; os, CStudentEmploy &amp;obj);
          friend istream&amp; operator&gt;&gt;(istream&amp; is, CStudentEmploy &amp;obj);
  
      };
  
  
      ostream&amp; operator&lt;&lt;(ostream&amp; os, CStudentEmploy &amp;obj) {
          os&lt;&lt;setiosflags(ios::left)&lt;&lt;setw(8)&lt;&lt;obj.GetName()
               &lt;&lt;"|"&lt;&lt;setw(11)&lt;&lt;obj.GetFacNum()
               &lt;&lt;"|"&lt;&lt;setw(8)&lt;&lt;obj.GetMinutes()&lt;&lt;endl;
          return os;
      }
  
  
      istream&amp; operator&gt;&gt;(istream&amp; is, CStudentEmploy &amp;obj) {
          string tmp_strName;
          string tmp_strFacNum;
          int tmp_iMinutes;
          is &gt;&gt; tmp_strName &gt;&gt; tmp_strFacNum &gt;&gt; tmp_iMinutes;
          obj.SetName(tmp_strName);
          obj.SetFacNum(tmp_strFacNum);
          obj.SetMinutes(tmp_iMinutes);
          return is;
      }
  
  
  
      class CAnalizeTime { 
      private:
          vector&lt;CStudentEmploy&gt;m_vData;
  
          void add(CStudentEmploy employ) {
              m_vData.push_back(employ);
          }
  
      public:
  
          CStudentEmploy getEmployAt(int i)
          {
              return m_vData[i];
          }
  
          long getEmployCount()
          {
              return m_vData.size();
          }
  
          CAnalizeTime()
          {
              ifstream fs;
              fs.open("test.txt");
              if(!fs.is_open()) cout&lt;&lt;"error opening file!\n";
              CStudentEmploy employ;
              while(!fs.eof())
              {
                  fs&gt;&gt;employ;
                  add(employ);
              }
          }
  
          CAnalizeTime(const string&amp; strFileName)
          {
              ifstream fs;
              fs.open(strFileName.c_str());
              if(!fs.is_open()) cout&lt;&lt;"error opening file!\n";
              CStudentEmploy employ;
              while(!fs.eof())
              {
                  fs&gt;&gt;employ;
                  add(employ);
              }
          }
  
          void Sort()
          {
              sort(m_vData.begin(),m_vData.end());
          }
  
          vector&lt;int&gt; calcNums(int iR1,int iR2,int iR3,
                                   int iR4,int iR5,int iR6)
          {
              vector&lt;int&gt; resultVector;
              for (int i=0;i&lt;5;i++)
              {
                  resultVector.push_back(0);
              }
              for (i=0;i&lt;m_vData.size();i++)
              {
                  if(m_vData[i].GetMinutes()&gt;=iR1
                               &amp;&amp;m_vData[i].GetMinutes()&lt;iR2) 
                                      resultVector[0]++;//[iR1-iR2)
                  if(m_vData[i].GetMinutes()&gt;=iR2
                               &amp;&amp;m_vData[i].GetMinutes()&lt;iR3) 
                                     resultVector[1]++;//[iR2-iR3)
                  if(m_vData[i].GetMinutes()&gt;=iR3
                                &amp;&amp;m_vData[i].GetMinutes()&lt;iR4) 
                                     resultVector[2]++;//[iR3-iR4)
                  if(m_vData[i].GetMinutes()&gt;=iR4
                              &amp;&amp;m_vData[i].GetMinutes()&lt;iR5) 
                                    resultVector[3]++;//[iR4-iR5)
                  if(m_vData[i].GetMinutes()&gt;=iR5
                               &amp;&amp;m_vData[i].GetMinutes()&lt;iR6) 
                                    resultVector[4]++;//[iR5-iR6)
              }
              return resultVector;
          }
  
          double calcMean() 
          {
              double sum=0;
              for (int i=0;i&lt;m_vData.size();i++)
              {
                  sum+=m_vData[i].GetMinutes();
              }
              return sum/m_vData.size();
          }
      };
  
      ostream&amp; operator&lt;&lt;(ostream&amp; os, CAnalizeTime &amp;obj) 
      {
          for (int i=0;i&lt;obj.getEmployCount();i++)
          {
              cout&lt;&lt;obj.getEmployAt(i);
          }
          return os;
      }
  
      void main() 
      {
          CAnalizeTime myTimeAnalyzer;
          //myTimeAnalyzer.Sort();
          cout&lt;&lt;setiosflags(ios::left)&lt;&lt;setw(8)
                  &lt;&lt;"Name"&lt;&lt;setw(12)
                  &lt;&lt;"|FacNum"&lt;&lt;setw(8)&lt;&lt;"|Minutes"&lt;&lt;endl;
          cout&lt;&lt;"----------------------------"&lt;&lt;endl;
          cout&lt;&lt;myTimeAnalyzer;
          cout&lt;&lt;"CalcMean result:"&lt;&lt;myTimeAnalyzer.calcMean()&lt;&lt;endl;
          vector&lt;int&gt;myCalcNums = myTimeAnalyzer.calcNums(1,50,100,200,400,800);
          cout&lt;&lt;"CalcNums result:"
                  &lt;&lt;myCalcNums[0]&lt;&lt;","
                  &lt;&lt;myCalcNums[1]&lt;&lt;","
                  &lt;&lt;myCalcNums[2]&lt;&lt;","
                  &lt;&lt;myCalcNums[3]&lt;&lt;","
                  &lt;&lt;myCalcNums[4]&lt;&lt;endl;
          system("pause");
          return;
      }
  </code></pre>
  
  <p>I'm getting this error when I run it on VC6 <code>error C2593: 'operator &gt;&gt;' is ambiguous</code>, and I get this error when I run it on 2010</p>
  
  <pre><code>1&gt;------ Build started: Project: test_project, Configuration: Debug Win32 ------
  1&gt;Build started 5/14/2013 10:02:29 PM.
  1&gt;InitializeBuildStatus:
  1&gt;  Touching "Debug\test_project.unsuccessfulbuild".
  1&gt;ManifestResourceCompile:
  1&gt;  All outputs are up-to-date.
  1&gt;LINK : error LNK2001: unresolved external symbol _mainCRTStartup
  1&gt;C:\Users\User\Desktop\test_project\test_project\Debug\test_project.exe : fatal error LNK1120: 1 unresolved externals
  1&gt;
  1&gt;Build FAILED.
  1&gt;
  1&gt;Time Elapsed 00:00:00.80
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>My question is what is causing this errors</p>
  
  <p>I have the errors here on these lines:</p>
  
  <pre><code>CAnalizeTime()
          {
              ifstream fs;
              fs.open("test.txt");
              if(!fs.is_open()) cout&lt;&lt;"error opening file!\n";
              CStudentEmploy employ;
              while(!fs.eof())
              {
                  fs&gt;&gt;employ;
                  add(employ);
              }
          }
  
          CAnalizeTime(const string&amp; strFileName)
          {
              ifstream fs;
              fs.open(strFileName.c_str());
              if(!fs.is_open()) cout&lt;&lt;"error opening file!\n";
              CStudentEmploy employ;
              while(!fs.eof())
              {
                  fs&gt;&gt;employ;
                  add(employ);
              }
          }
  </code></pre>
  
  <p>This is what the error message looks like:</p>
  
  <pre><code>--------------------Configuration: project_testing - Win32 Debug--------------------
  Compiling...
  project_testing.cpp
  D:\My Documents\project_testing\project_testing\project_testing.cpp(143) : error C2593: 'operator &gt;&gt;' is ambiguous
  D:\My Documents\project_testing\project_testing\project_testing.cpp(156) : error C2593: 'operator &gt;&gt;' is ambiguous
  Error executing cl.exe.
  
  project_testing.obj - 2 error(s), 0 warning(s)
  </code></pre>