Outside the Class Definition

Member functions that are declared inside a class have to be defined separately outside the class. Their definition are very much like the normal functions. They should have a function header and a function body. Since C++ does not support the old version of function definition, the ANSI prototype from must be used for defining the function header.

An important difference between a member function and a normal function is that a member function incorporates a membership identity label in the header. This label tells the compiler which class the function belongs to. The general form of a member function definition is:
return_type class_name :: function_name (argument declaration)
{
function body
}

No comments:

Post a Comment