c++ pointer assignment operator overload(not just object assignment but pointer assignment)

后端 未结 3 1848
灰色年华
灰色年华 2020-12-12 05:27

Is there a way to overload the pointer assignment operator? e.g. overload pointer assignment operator for class A when

A *x, *y;
x = y;
3条回答
  •  死守一世寂寞
    2020-12-12 05:52

    There is no "pointer assignment operator". This is the assignment operator and you are using it with pointer operands.

    It's not possible to overload an operator unless at least one operand has class or enum type. (Pointer type is not class type).

提交回复
热议问题