Member functions (methods)
Defined either inline in the class definition or outside.
The outside member
functions must indicate the class they are part of.
The 'Class_name::' part is called the scope resolution operator
It tells the compiler that this function is part of the class class_name.
Return type
Class_name::function_name
Member functions don't have to specify the private members of the class.
For example, in the C version of a function that examined the value of an
element in a structure, the structure was passed as a pointer to the function.
void
foo(struct martha * one) {
printf("%d",one->item);
}
In C++, the pointer is implicit and the elements can be simple variables in the
private part of the class. so
void
foo() {
printf("%d",item);
}
item can be treated as a parameter to the function.
There is a pointer to the data in the class instance
avaliable called this.
So the variable above was useable as
this->item;