C++ static operator overloading

后端 未结 4 818
无人及你
无人及你 2021-02-15 17:06

Is it possible to overload C++ class operators in the static context? e.g.

class Class_1{ ... }
int main()
{

    Class_1[val]...

}
4条回答
  •  悲哀的现实
    2021-02-15 17:27

    If you mean the operator operates on a class, the No. That does not make sense, it is like saying operator + may operator on int or double. Operators are syntactic sugar for functions and they operate on varibles(values) not types.

提交回复
热议问题