Do getters and setters impact performance in C++/D/Java?

后端 未结 10 2340
无人及你
无人及你 2020-12-06 09:26

This is a rather old topic: Are setters and getters good or evil?

My question here is: do compilers in C++ / D / Java inline the getters and setter?

To which

10条回答
  •  离开以前
    2020-12-06 09:36

    In C++, when a compiler's optimizations are enabled then getters and setters may be 'inlined': i.e., be implemented using the same machine instructions as there would be for direct access to the underlying member data.

提交回复
热议问题