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: Anonymous 2013-02-23 16:32

It's C++, man. Every newbie invents his own string class and uses it all around his projects.
No, from where I work it seem that C++ community is somehow becoming somewhat organized and less retarded. I don't know how or why it happens, but, you know, the Channel9 talk where the guys said that cool people pass smart pointers by const reference, it trickles down somehow, for example. Like, people who are in the know feel free to ridicule people who do it wrong, and all bystanders watch and learn and perpetuate our harsh truths.

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