Department of Computer Science
University of Wyoming

COSC 2409, Summer 1997


Last update: 30 October, 1996; R. Hill
1. Missing semicolon. (Or, extraneous semicolon.)
They belong here:
if (blah) then f1(); else f2();
But not here:
for ( i=0; i<n; i++ ) blah();
2. No memory allocation for string.
You can treat an array of character as a string, and use a pointer to access it, but if you read it in from input, you have to allocate memory for it, as a char array with an adequate number of members.

3. Badly nested brackets.
Check them carefully. Better yet, label at least each closing bracket with a comment.

4. Case inconsistency in identifiers.
Remember, "NewItem" is not the same as "newitem."

5. Using "=" for equality.
That's the assignment operator. You want the double equal sign "==."

6. Using "&" and "|" for logical functions.
These are bitwise operations. You want "&&" and "||," for "and" and "or," respectively.

7. Reference before declaration.
All identifiers must be declared before they are used; classes, for example, must be declared before they are used to declare members of other classes.

8. Omitting parentheses from function call.
This statement:
where "foo" is a function, is not a compiler error, but it is not a function call, even if "foo" has an empty argument list. You want:
But see below.

9. Using parentheses in declaring objects.
If you intend to declare an object obj of class C, using the default constructor and passing no arguments, this statement:
                       C obj();
Will not do it! It will be interpreted as a function prototype. You want:
                       C obj;

10. Leaving base class members private.
This is not an error, of course, unless you want the methods of derived classes to be able to access them. And you probably do. You want "protected."

[Hit Counter]