If statements with string values?

I'm trying to make a program where if the user types "Yes" a certain statement appears , and else another statement, but I don't get how to do it? I can't use bool, and std::string is not convertible to bool. Please help. Total beginner here.
Please show what you're trying to do.

1
2
3
4
5
6
7
8
  std::string ans;
  std::cin >> ans;
  if (ans == "Yes")
  {  // Do one thing
  }
  else
  {  // Do another thing 
  }


std::string is not convertible to bool, but the std::string class provides comparison operators.
Last edited on
That's exactly what I was trying to do, only I've been trying to type (ans="Yes") for 2 hours, didn't know I needed ==. Thanks so much!
= is the assignment operator. == is the equality operator.
http://www.cplusplus.com/doc/tutorial/operators/
Topic archived. No new replies allowed.