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;
};

Name: Anonymous 2013-02-24 6:36

>>34
That blog post was shot down pretty hard in the comments.

Name: Anonymous 2013-02-24 7:27

>>41
That gets what's desired in this case, and it's concise, but you no longer have the ability to have a person without the linked list node embedded in. That's what disappointed me about their use of C in the blog, and the in the comments.

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-02-24 7:38

>>42
What comments?

Name: Anonymous 2013-02-24 7:59

>>41
I dislike C++: it is too verbose, complicated and obfuscated:

Symta:
<Age:|Weight:>

C/C++:

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

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

Name: Anonymous 2013-02-24 8:03

>>44
The comments for the blog post.

Name: Anonymous 2013-02-24 8:11

>>45
is it an associative array? python, php, js etc dinamic crap can create it in a similar way

Name: Anonymous 2013-02-24 8:37

>>47
No. It's lambda.

Name: Anonymous 2013-02-24 10:58

>>45
I LOVE YOU, NIKITA

PLEASE DOCUMENT SYMTA

Name: Anonymous 2013-02-24 12:43

>>49
Talk is cheap. Show me the code. -- Linus Torvalds

Name: Anonymous 2013-02-24 13:10

Whores are cheap. Show me your anus. -- Terry Pratchett

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