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

后端 未结 7 2343
清酒与你
清酒与你 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条回答
  •  有刺的猬
    2020-12-30 06:29

    I would make it a boost::shared_ptr. You can be pretty rough with these and they take care of themselves. Whereas using a raw pointer means tha you have to worry about that object being kept alive

提交回复
热议问题