shangping shangping - 1 year ago 80
C++ Question

Can I create a new operator in C++ and how?

MATLAB arrays support matrix operations and element operations. For example,

. This is a quite intuitive way to distinguish ‎the two different operations. If I want to implement similar operations in C++, how can I do that?

Can I create a new operator,
, too? If yes, can anyone give me some guidance?

Answer Source

Here's a nice tutorial on operator overloading. Here's an example on how to create custom operators.

Note however that custom operators are not supported by C++ per se, the example above uses tricks with macros to achieve the effect. I wouldn't do it if I were you, and use functions instead. Without tricks - custom operators are not supported in C++.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download