Declaring Variables

Place the pointer or reference indicator next to the type name. Don't put it next to the variable name or place it with a space on either side. In other words, do this:

   char* foo;
   int& theInt;

And not this:

   char *foo;
   int &theInt;

Only declare a single variable on any line. Combining this rule with the last one will prevent you from writing something like this:

   int* varOne, varTwo;

If you were to write this, you would have declared one pointer and one integer variable, when in fact you meant to declare two pointers.

© 1998 by Wrox Press. All rights reserved.