neither. use <string> which is standard c++. char array / char* is C and works but its 1990s era code. CString is a horrible microsoft invention that is a poor quality wrapper for char array, on par with a homework assignment to make your own string class. To be fair, it predates <string> so they felt it was useful way back when.
what exactly do you want to compare? <string> has == built into it. CString probably does too, or I thought it did. Maybe that was one of the reasons I hated it... I know it is missing critical things, but can't recall what.
use npos for find failures:
if(vit == std::npos) I think, or very nearly ... look it up if you need to see it (sorry, I dont do this much). npos is usually -1 but you can't rely on it.
I do not know what a string xor is :) (yes, I know, but I stubbornly refuse to allow M$ to screw up another language, I deny their abominations).
I don't think static matters here. but I could be wrong, let us know which string you do end up choosing and we can look again from that angle.
I mean, this works, but I am not sure you need it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
struct fu
{
static string s;
bool operator ==(string& z) {return z == s;}
};
string fu::s = "moo";
int main()
{
fu f;
string l{"words"};
string m{"moo"};
if(f == l) cout << "really?";
if(f == m) cout << "really!";
}
|
its a lot of handwaving to say:
if(fu::s == m) //one point/beauty of static class members is you can just access them...
this may be incomplete ... most people would expect if you have this == you would also have fu == other fu