Do getters and setters impact performance in C++/D/Java?
问题 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 extent do the getters/setters impact performance (function call, stack frame) compared to a direct field access. Besides all the other reasons for using them, I would like to know whether they are supposed to affect the performance besides being a good OOP practice. 回答1: It depends. There is no universal answer that is always going to be