Member Functions
- A function is a Member Function if it can be declared as a member of the class
(Function declaration or de nition within the class).
- It operates on any object of the class of which it is a member, and has access to all the
members of a class for that object (public as well as private).
How to define member functions?
1. Within the class
- A member function will be called using a dot operator (.) on an object.
fi
2. Outside the class (using Scope Resolution Operator(::))
- Here, only important point is that you would have to use class name just before ::
operator.
- Scope of the function is restricted to the class name given.
- Calling the member function is same as before.
Features of Member Functions
- Several classes can use same function names, the con ict will be resolved by the
membership label.
- Member functions can access all data of its class(whether private or public).
- A member function can call another member function directly without using (.) operator.
fl