Electron microscopy
 
Operator Overloading in C++
- Practical Electron Microscopy and Database -
- An Online Book -
Microanalysis | EM Book                                                                                   http://www.globalsino.com/EM/        


=================================================================================

 

In DM as well as C++, operators can be overloaded relative to class types which is defined. The principal advantage of overloading operators is that new data types is integrated seamlessly into the programming environment. Operator overloading allows to define the meaning of an operator for a specific class. For instance, a class, which defines a linked list, can use the + operator to add an object to the list. A class that implements a stack can also use the + to push an object onto the stack. Another class can use the + operator in an entirely different way. In this case, when an operator is overloaded, none of its original meaning is lost. Operator overloading is, in fact, related to function overloading. To overload an operator, one needs to define what the operation means relative to the class, which it is applied to. To do this, an operator function is created so that the action of the operator is defined.

The operator functions can be either members or non-members of a class. However, non-member operator functions are often friend functions of the class. Although they are similar, there are still some differences between the way a member operator function is overloaded and the way a non-member operator function is overloaded.

However, DM does not allow operator overloading.

 

 

 

=================================================================================