Member function that is declared inside a class has to be defined separately outside the class. These member functions associate a membership identify label in the header. This label tells the compiler which class the function belongs to.
Syntax of a member function definition is.
Return type class name:: function-name(argument declaration)
{
Function body
}
The membership label class-name:: tells the compiler that the function function-name belongs to the class-name. The symbol :: is called as scope resolution operator.
Ex- the function getdata is coded as
void item:: getdata(int a, float b)
{
number = a;
cost = b;
}
The member function have some special characteristics :- i) Several different classes can use the same function name the membership label will resolve their scope. ii) Member function can access the private data of the class. A non member function cannot do so. iii) A member function can call another member function directly, without using the dot operator.