Non-static const member, can't use default assignment operator

后端 未结 4 1647
北海茫月
北海茫月 2020-11-27 04:45

A program I\'m expanding uses std::pair<> a lot.

There is a point in my code at which the compiler throws a rather large:

N

4条回答
  •  心在旅途
    2020-11-27 05:23

    At least mention which object the compiler is complaining about. Most probably you are missing a custom assignment member. If you don't have one, the default one kicks in. Probably, you also have a const member in that class (whose objects are being assigned) and since a const member cannot be changed you hit that error.

    Another approach: Since it's a class const, I suggest that you change it to a static const if that makes sense.

提交回复
热议问题