Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Operator Overoverloading

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-02-22 6:56

Studying part of a large complex middleware for a management web application, and wondering why this:
InitechString str1, str2;
...
if(!(str1 != str2))
{
    ...
}


occurred almost as often as this:
InitechString str1, str2;
...
if(str1 == str2)
{
    ...
}


I dug a little deeper and found...


// CASE-SENSITIVE COMPARISON
//
int InitechString::operator==(const InitechString& r) const
{
    return !strcmp(m_ptr, r.m_ptr);
}
// CASE-NONSESTIVE COMPARISON
//
int InitechString::operator!=(const InitechString& r) const
{
    return !!strcmp(m_ptr, r.m_ptr);
}

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-02-24 6:31

>>34
That's a problem with the programmer/education, not the language.

template class dllist<typename T> {
 struct dllist<T> *prev;
 struct dllist<T> *next;
};

class person : public dllist<person> {
 int age;
 int weight;
};

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List