Applying qualifiers to data members and member functions
In this section, we will investigate qualifiers that can be added to both data members and member functions. The various qualifiers – inline
, const
, and static
– can support program efficiency, aid in keeping private data members safe, support encapsulation and information hiding, and additionally be used to implement various object-oriented concepts.
Let’s get started with the various types of member qualifications.
Adding inline functions for potential efficiency
Imagine a set of short member functions in your program that are repeatedly called by various instances. As an object-oriented programmer, you appreciate using a public
member function to provide safe and controlled access to private
data. However, for very short functions, you worry about efficiency. That is, the overhead of calling a small function repeatedly. Certainly, it would be more efficient to just paste in the two or three lines...