Class Member Functions

In this lesson, we will highlight the role of member functions in classes.

The Purpose of Member Functions

Member functions define the behaviour of the class.

These functions can either alter the content of the data variables or use their values to perform a certain computation. Typically, member functions are declared as public, although, some functions which do not need to be accessed from the outside could be kept private.

Declaration and Definition

Like all functions, member functions can either be defined straightaway, or they could be declared first and defined later.

Here’s an example of a function being defined in the class:

Get hands-on with 1200+ tech skills courses.