How to call an operator as function in C++

后端 未结 6 2227
执念已碎
执念已碎 2021-02-19 11:04

I want to call a specific operator of specific base class of some class. For simple functions it\'s easy: I just write SpecificBaseClass::function( args );. How sho

6条回答
  •  借酒劲吻你
    2021-02-19 11:13

    There are two notions in C++: one is operator, and the other is operator-function. Operator informally is what is broadly called a built-in operator. You cannot call them in functional notation. Operator-function is what is called an overloaded operator which you can call as already is seen from many answers: that is, if @ is a member binary operator of class A, then someObjectOfTypeA.operarot@(someOtherObject), or if it is a freestanding function, then like operator@ (object1, object2)

提交回复
热议问题