I have a class called AString . It is pretty simple:
class AString { public: AString(const char *pSetString = NULL); ~AString(); bool operator==(const AString &pSetString); ... protected: char *pData; int iDataSize; }
Now I want to write code like this:
AString *myString = new AString("foo"); if (myString == "bar") { }
However, the existing comparison operator only supports
if (*myString == "bar")
If I omit the asterisk, the compiler is unhappy.
Is there a way for the comparison operator to compare *AString with const char* ?
c ++ pointers comparison-operators operator-overloading
bastibe
source share