• Day algorithm [more] 第五十四期 • Knowledge Literacy: What is the operator?

Preface ▎

  This long and stuff like iterators, but more common than iterators.

  Talking today to operator.

▎ defined

  operator is C #, C ++, and pascal keyword, it operators used in conjunction operator represents a function, the operator = should be understood that as a whole the function name.

This is the C ++ and pascal extension operators method function, it might look odd, but may also be understood: one operator to make use of its original consistency, on the other hand can extend its capabilities by way function (in C ++, "function" is a function implemented).

  In symbian os c ++, returns const TUint & single descriptor data to a specified data item . Use of operator [] in the descriptor loop of the cost is expensive; alternative approach is to consider the use of C ++ arithmetic pointer and TDesc :: Ptr ().
  Application of the operator in .Net, .Net the template in its ready state machine has a set of operations, as needed Add + =; requires Rmove - =  [. 1]   reload operation, when more "lines" ; (copy from Baidu Encyclopedia)
  I believe you probably know, operator deals with operators, called the standard terminology overloaded operators.
▎ Why operator?
  • Because C ++ provides operators only supports standard operators operator
  • Operator using the operator may be redefined
  • Used for structure
▎ how to use operator?
  This simple, direct template goes:
Operator Return Type operator (parameter) 
{ 
        return returned content; 
}

  E.g:

  node type structure is customized.

int operator+(node x)
{
    return x.a+x.b;
}

Guess you like

Origin www.cnblogs.com/TFLS-gzr/p/11394422.html