Error while overloading operator (must be a nonstatic member function)

前端 未结 2 1012
野性不改
野性不改 2020-12-29 05:48

I\'m writing string class on my own. And I have such code. I just want to overload operator=. This is my actual code, and I get error in last part of code.

2条回答
  •  离开以前
    2020-12-29 05:56

    I believe PiotrNycz has provided the reasonable answer. Here please pardon me to add one more word.

    In c++, assignment operator overloading function couldn't be friend function. Using friend function for operator=, will cause the same compiler error "overloading = operator must be a nonstatic member function".

提交回复
热议问题