Search code examples
c++fstreamextractfileparsing

What does invalid operand to binary expression mean?


I am new to C++ and want to parse a line from a file. I am using fstream and extractors. I keep receiving the following error in xcode:

invalid operand to binary expression.

I have no idea what this means. I looked long and hard and have not been able to find anything helpful.

int x;
int y;
fileIn >> x >> y;

The error is on the third line. fileIn is an fstream object that is static and declared and instantiated in another method that is located in the same class. Thanks for your time.


Solution

  • Because you say "fileIn is an fstream object that is static and declared and instantiated in another method that is located in the same class" I guess it is a pointer, really.

    Therefore, the syntax should be:

    (*fileIn) >> x >> y;