Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with error C2679.

Status
Not open for further replies.

Deracial

Programmer
Nov 1, 2003
2
JP
Heres my problem. I tried to compile this program and I am getting error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::all
ocator<char> >' (or there is no acceptable conversion)

I have read the other posts but they are not useful. Here are the lines of error and the relevant code. Not all of the code is here..just the lines indicated by error messages.

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
cin >> in_file; // Both of these are for reading

cin >> out_file; // and writing to a file.

inData >> first_name >> middle_name >> last_name >> grade >> month;

first_init = first_name.substr(1,1);

middle_init = middle_name.substr(1,1);

last_init = last_name.substr(1,1);

return 0;
}

Like I said, this is not all of the code...only the affected lines. If anyone could help I would be in their debt. :p
 
Oops. I forgot to include <string>.

I did that and it fixed the first 3 lines of problems. However the last 3 are still bad...
 
> Not all of the code is here..just the lines indicated by error messages.
But without some important information (like how you declared those variables for instance), it's pretty meaningless to look at just the 6 lines which corresponded to the 6 error messages.

It's best if you create a small program which demonstrates the problem, then post the entire program here.

--
 
I think the problem is there:
inData >> first_name >> middle_name ..

The operator >> is not defined for std::string. I suppose first_name and middle_name aer std::string's.


Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top