Operator Overloading in C

Posted by Leif Andersen on Stack Overflow See other posts from Stack Overflow or by Leif Andersen
Published on 2010-04-10T03:03:17Z Indexed on 2010/04/10 3:13 UTC
Read the original article Hit count: 349

Filed under:
|
|
|

In C++, I can change the operator on a specific class by doing something like this:

MyClass::operator==/*Or some other operator such as =, >, etc.*/(Const MyClass rhs) {
    /* Do Stuff*/;
}

But with there being no classes (built in by default) in C. So, how could I do operator overloading for just general functions?

For example, if I remember correctly, importing stdlib.h gives you the -> operator, which is just syntactic sugar for (*strcut_name).struct_element.

So how can I do this in C?

Thank you.

© Stack Overflow or respective owner

Related posts about c

    Related posts about operator-overloading