Copying a C++ class with a member variable of reference type

后端 未结 7 2391
清酒与你
清酒与你 2020-12-30 06:06

I\'ve a class which stores a reference to its parent, the reference is passed in the constructor. If I try to copy an instance I get an error \"error C2582: \'operator =\' f

7条回答
  •  梦毁少年i
    2020-12-30 06:41

    Yes, if you need to support assignment, making it a pointer instead of a reference is nearly your only choice.

提交回复
热议问题