What does “operator = must be a non-static member” mean?

后端 未结 4 1060
眼角桃花
眼角桃花 2020-11-28 13:24

I\'m in the process of creating a double-linked list, and have overloaded the operator= to make on list equal another:

template
void operator=         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 14:02

    From C++ Standard, "Binary Operators":

    "A binary operator shall be implemented either by a non-static member function with one parameter or by a non-member function with two parameters"

    It wants you to define this in a class, as a member, or make it a static method (in which case it should take two parameters (for both the lval and the rval).

提交回复
热议问题