Reputation: 99
I know I'm sounding an awful lot like a newb by asking this however I'm curious as to know why I'm getting an error when using simple operators through an if statement on a string? Here is what I am doing to produce the error:
void Shift (string updown )
{
if (updown == "hel")
{
//random code
}
}
and my includes would be:
#include <iostream>
#include <fstream>
#include <Windows.h>
using namespace std;
Upvotes: 2
Views: 320
Reputation: 612
You are attempting to use the std::string class without actually including the necessary header.
Add #include <string>
to your list of includes.
Upvotes: 0
Reputation: 283634
You forgot
#include <string>
Other header files might include the internal header that provides the std::string
class, but without the associated functions such as the ==
operator you're missing.
Upvotes: 1
Reputation: 145269
Well, you know, try to include the <string>
header. And either write std::string
or add a using std::string
after the include.
Upvotes: 5