1 2 3 4 5 6 7 8 9 10 11 12

Private, Public and Protected
To limit access to member variables, or member functions, to other member functions defined in the same class, then place them in the private part of the class definition.

To limit access to member variables/functions to other member functions defined in a subclass, then place them in the protected part.

To prevent member variable re-assignment, but yet enable readability of those variables, place them in the private part, but define member-variable readers (access functions) in the public or protected part. C++ programs normal use call by value parameters. Thus the value of any argument is copied input memory local to the function (reserved for that parameter). This the actual argument is protected from local change.

You can force the C++ compiler to treat the parameter as call-by- reference, by using the &appendage to the formal parameter. Thus the corresponding actual parameter can change through local actions in the function.

DataType FunctionName ( ..., DataType& ParameterName, ... );
void swap (int&, int&);

24-Mar-98

Page 6

TAM/C201