In C++ the std::string
class implements the comparison operators, so you can perform the comparison using ==
just as you would expect:
if (string == "add") { ... }
When used properly, operator overloading is an excellent C++ feature.
More Related Contents:
- Program to overload < and > to compare two strings [closed]
- Comparing strings lexicographically
- What is the proper function for comparing two C-style strings?
- Read whole ASCII file into C++ std::string [duplicate]
- How do I read an entire file into a std::string in C++?
- How can I convert a std::string to int?
- Legality of COW std::string implementation in C++11
- C++ convert string to hexadecimal and vice versa
- How to get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC?
- Difference between string and char[] types in C++
- Does std::string have a null terminator?
- how to check if given c++ string or char* contains only digits?
- Why I cannot cout a string?
- What exactly is the L prefix in C++?
- Compare version numbers without using split function
- Convert wstring to string encoded in UTF-8
- reading a line from ifstream into a string variable
- Modifying a char *const string
- How to append a char to a std::string?
- Why am I getting string does not name a type Error?
- Escaping a C++ string
- Why “initializer-string for array of chars is too long” compiles fine in C & not in C++?
- c++ parse int from string [duplicate]
- Is writing to &str[0] buffer (of a std:string) well-defined behaviour in C++11?
- Hash function for a string
- How to write an object to file in C++
- convert string to integer in c++
- How to convert int to string in C++
- What’s the difference between istringstream, ostringstream and stringstream? / Why not use stringstream in every case?
- Assign a string literal to a char* [duplicate]