The purpose of member functions is to open an interface. There is no need to make getters and setters or other trivial functions, just move the interfaces already implemented by members into an aggregated container object.
If the Student client should be allowed to manipulate scores , but they want to, you must make scores public member and access it in a simple way. If it should be a stack with push , pop and top , use the std::stack interface adapter. If only push_back allowed, you can implement addToScores . But if you are the only client, and you donโt care that other parts of the std::vector interface are being abused, there really is no point in introducing a new interface.
Each interface within the program should be thought out. Adding slapdash interfaces as a habit, since standard interfaces (including the default C ++ assignment operator) are "dangerous", not necessarily a good habit.
source share