Ask coding questions

← Back to all posts
invalid operands to binary expression
h
Emphices (0)

little brain dead rn but would greatly appreciate it if someone could help me with this. The error says "[cquery] invalid operands to binary expression ('std::basic_istream<char, std::char_traits<char> >::__istream_type' (aka 'basic_istream<char, std::char_traits<char> >') and 'int')" line 68.

Answered by CSharpIsGud (1061) [earned 5 cycles]
View Answer
Comments
hotnewtop
CSharpIsGud (1061)

The read function doesn't return how many bytes read. To tell if its all been read you should do this instead:

if(infile.read(reinterpret_cast<char*>(this), sizeof(*this))) {
    show_data();
}

I am also certain you should not be overwriting this like that and should be making a new one for each entry.