Getters and Setters. Is there performance overhead?

后端 未结 4 1866
余生分开走
余生分开走 2021-02-01 13:54

I have a Particle System Engine in my C++ project and the particles themselves are just structs of variables with no functions. Currently, each particle (Particle) is updated fr

4条回答
  •  轮回少年
    2021-02-01 14:50

    Getters and setters allow your code to evolve more easily in the future, if getting and setting turn out to be slightly more complicated tasks. Most C++ compilers are smart enough to inline those simple methods and eliminate the overhead of the function call.

提交回复
热议问题