C++ Programming Code Examples C++ > Beginners Lab Assignments Code Examples Access Functions in C++ programming language Access Functions in C++ programming language Encapsulation is achieved using access specifiers. In encapsulation we make all member variables private and provide public functions which allow user to work with the class. These functions are called as access functions. Access functions are used to return the value of private member variables. There are two types of access functions Getters: Functions which return the value of private member variables of the class. Setters: Functions which set the value of the private member variables of the class. class Game { private: int m_Score; int m_Rank; public: // Getters int GetScore() { return m_Score; } int GetRank() { return m_Rank; } // Setters void SetScore(int iScore) { m_Score = iScore; } void SetRank(int iRank) { m_Rank = iRank; } };