zoukankan      html  css  js  c++  java
  • [C++] Operator Overload

            Operator Overload

     NOTE1:

       operator = must be overload as a member function

    NOTE2:

      An operator function must either be a member of a class or have at least one parameter of class type.

     

    //操作符重载,有一个最基本条件,就是一定有一个一元是一个自定义的C++类
    //如果两个都是基本数据类型操作符重载是非法的

    NOTE3:

     An overload operator function has the same number of parameters as the operator has operands .

     A unary(一元) opeartor has one parameter;

     A binary(二元)  opeartor has two parameter ,the left-hand operand is passed to thr first parameter

     and the right-hand operand to the second .

     

    NOTE4:

       When an overloaded operator is a member function , this is bound to left-hand operand.

       Member operator functions have one less(explict) parameter than the number of opeands.

     成员操作函数少一个隐式参数:this

    NOTE5:

    //如果返回的是char,代表的是一个右值,右值是不能直接赋值的,
    //如果返回的是char的引用,那么[]就可以当左值使用了


  • 相关阅读:
    Sass-unitless()函数
    Sass函数:unit()函数
    Sass函数:Introspection 函数 -type-of()
    Sass函数-值列表index
    Sass函数--列表函数append
    Sass函数-join()函数
    Sass函数:列表函数nth
    Sass函数:值列表函数length
    Sass函数:random()函数
    学习笔记77—Iphone集
  • 原文地址:https://www.cnblogs.com/tianhangzhang/p/4906490.html
Copyright © 2011-2022 走看看