TOC PREV NEXT

C constructs to avoid


Certain features of the C programming language that also exist in C++ will not be allowed for programming you do in CS 9F. These features, we think, are either particularly confusing or likely to lead to hard-to-find bugs. The forbidden features of C are the following:

use of ++ or -- within a larger expression

C-style arrays and strings, i.e. any declaration of the form

	type var-name [ ]

(use the vector class instead)

pointer arithmetic, or any use of the * operator where alternative C++ constructs, e.g. reference parameters or a vector class, are more appropriate

dynamically allocated C-style arrays using new [ ] or delete [ ] (use the vector class instead)

#define to define constants, except in the first two lines of a .h file (use const instead)

any of the functions declared in stdio.h (use functions declared in iostream.h instead)

malloc, free, sizeof (use new and delete)

the & ("address of") operator, except in the header of a function to indicate a reference parameter

unions

goto


TOC PREV NEXT