Puzzling errors

Apr 18, 2013 at 2:58pm
I'm experiencing error c2678 in my header file. I'm suffering this in many places, but I'll only show you the first error's relevant code:

#include<iostream>
#include<ctime>
#include<time.h>
#include<cstdlib>
#include<windows.h>
class whatever{
public:
std::string line;
//some other variables
};
int someFunction(int num, std::string text, whatever &whatever1/*object of class whatever*/, std::string arrayOfStrings[]){
if(text == whatever1.line)//the error is on this line
{
//some more code
}
//some more code
return 0;
}

The error message reads exactly: "binary '==' : no operator defined which takes a left-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::a
llocator<char> >' (or there is no acceptable conversion)"

I hope I didn't make some kind of stupid error, but whether it's a stupid error or not, I can't figure it out. Can anybody help?
Apr 18, 2013 at 3:19pm
Try adding this line
 
#include <string> 
Apr 18, 2013 at 3:37pm
and if that don't work (but it should), you could use compare() instead of ==

http://www.cplusplus.com/reference/string/string/compare/

Last edited on Apr 18, 2013 at 3:37pm
Apr 19, 2013 at 12:51am
Why do you include both ctime and time.h?
Apr 19, 2013 at 2:24pm
Adding #include<string> worked! Thanks, Chervil.
Topic archived. No new replies allowed.