H.A.7.1 o PP7

PROGRAMMING POINTERS, LESSON 7

 

Syntax/correctness issues

 

7-1        When declaring multiple reference parameters, each value must have its own & symbol.  The following is not valid:

 

             int  doSomething  (int &x, y, z);           //  syntax error

 

7-2        A reference variable must be initialized when it is declared.

 

7-3        A reference variable cannot be reassigned to another variable once it has been initialized.

 

7-4        A compiler-specific observation:  when coding a function template for swap in Turbo C++ 3.0, the function prototype needs the names of the parameters which will be used in the function implementation later in the source code.  Note, this requirement for identifiers in the function prototype only applies to templated functions.

 

 

Formatting suggestions

 

             none

 

 

Software engineering

 

7-5        When passing large objects which will not be changed, use a constant reference parameter to gain the efficiency of call-by-reference and the security of a simulated call-by-value.