Using reference as class members for dependencies

后端 未结 7 660
自闭症患者
自闭症患者 2020-12-13 01:06

I am going back to C++ after spending some time in memory-managed languages, and I\'m suddently kinda lost as to what is the best way to implement dependency injection. (I a

相关标签:
7条回答
  • 2020-12-13 01:38

    I would steer clear of references as members since they tend to cause no end of headaches if you end up sticking one of your objects in an STL container. I would look into using a combination of boost::shared_ptr for ownership and boost::weak_ptr for dependents.

    0 讨论(0)
提交回复
热议问题