Calling this->get/this->set methods versus directly accesing member variables in C++

前端 未结 8 636
挽巷
挽巷 2021-01-18 18:21

Suppose I have a class Foo, with a private variable bar_ containing some state for Foo. If necessary, I may write public get/set metho

8条回答
  •  借酒劲吻你
    2021-01-18 19:18

    I prefer to use get/set function. Because I found that it is very hard to debug if use member variable directly. Especially when you have a big class and there are a lot functions access bar_.

提交回复
热议问题