Move constructor and const member variables

前端 未结 5 953
自闭症患者
自闭症患者 2020-12-30 21:24

I like the idea of const member variables especially when I wrap C functions into classes. The constructor takes a resource handle (e.g. a file descriptor) that stays valid

5条回答
  •  时光说笑
    2020-12-30 21:37

    Reference counting is standard approach that solves your problem. Consider adding reference counting to your class; either manually, or using existing tools like boost shared_ptr.

提交回复
热议问题