470,810 Members | 2,155 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

How to fix "C2679: binary '>>' : no operator found" error?

Error 1 error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string lastName1, firstName1, lastName2, firstName2, lastName3, firstName3;
  9.     double currentSalary1, currentSalary2, currentSalary3;
  10.     double percentPayIncrease1, percentPayIncrease2, percentPayIncrease3;
  11.     double updatedSalary1, updatedSalary2, updatedSalary3; 
  12.  
  13.     ifstream fin;
  14.     ofstream fout;
  15.  
  16.     fin.open("Ch3_Ex8Data.txt");
  17.     fout.open("Ch3_Ex8Output.txt");
  18.  
  19.     fin >> lastName1 >> firstName1 >> currentSalary1 >> percentPayIncrease1;
  20.     fin >> lastName2 >> firstName2 >> currentSalary2 >> percentPayIncrease2;
  21.     fin >> lastName3 >> firstName3 >> currentSalary3 >> percentPayIncrease3;
  22.  
  23.     updatedSalary1 = currentSalary1 * percentPayIncrease1 + currentSalary1;
  24.     updatedSalary2 = currentSalary2 * percentPayIncrease2 + currentSalary2;
  25.     updatedSalary3 = currentSalary3 * percentPayIncrease3 + currentSalary3;
  26.  
  27.     fout << firstName1 << lastName1 << updatedSalary1;
  28.     fout << firstName2 << lastName2 << updatedSalary2;
  29.     fout << firstName3 << lastName3 << updatedSalary3;
  30.  
  31.     fin.close();
  32.     fout.close();
  33.  
  34. return 0;
  35. }
Feb 6 '11 #1
1 2582
horace1
1,510 Expert 1GB
try adding
Expand|Select|Wrap|Line Numbers
  1. #include <string>
  2.  
otherwise what line is the error on?
Feb 6 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by IMS.Rushikesh | last post: by
2 posts views Thread by sony.m.2007 | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.