set/get methods in C++
问题 Java programmers and API seems to favor explicit set/get methods. however I got the impression C++ community frowns upon such practice. If it is so,is there a particular reason (besides more lines of code) why this is so? on the other hand, why does Java community choose to use methods rather than direct access? Thank you 回答1: A well designed class should ideally not have too many gets and sets. In my opinion, too many gets and sets are basically an indication of the fact that someone else