Member functions are written just like any other functions.
One difference, though, is they can use the data member names as is.
Thus, the member functions in
in an unqualified manner.
When invoked on a particular object
the member functions act on a specified member of that object.
Member functions that are defined within the
are implicitly inline.
As a rule, only short, heavily used member functions should be defined with the
Other member functions should be defined external to the
. We will look at defining external member functions in the next module.
At the level of programming, a class is a data structure with
- data members for representing the various properties of the different object instances of the class, and
- with member functions for representing the behavior of the class.
Click the Exercise link to add a member function to the
Member Function - Exercise