|
-
June 13th, 2002, 10:47 AM
#1
Comparison Operator Overloading
I have created a class for which I would like to overload the == operator. The name of the class is String. The problem I am running into comes into play when the object is a pointer..
String *a = new String();
if (a == "") return true; //error in VC++
the following operators are defined in the string class..
class String
{
bool operator ==(char *);
friend bool operator==(String &, char *);
}
I tried adding:
friend bool operator==(String *, char *);
but I get a compiler error.. What to do?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|