Which of the following are the correct preprocessor commands necessary to prevent multiple inclusions of header files? If there is an answer here that works to prevent multiple inclusion, carefully describe how it works in the explanation.

a. #include “header.h”
b. #define HEADER_H
#ifndef HEADER_H
//declarations for header.h go here
#endif
c. #ifndef HEADER_H
#define HEADER_H
// declarations for header.h go here
#endif
d. #ifndef HEADER_H
//declarations for header.h go here
#endif


c) is correct.
Explanation: c) The first time header file header.h is encountered, HEADER_H will not have been defined as a preprocessor symbol, so the #ifndef HEADER_H will permit inclusion of the following lines of code. The next line #define HEADER_H defines the symbol HEADER_H, so that if this file is encountered in a later inclusion, its contents will be skipped. The necessary definitions and declarations are placed next. The #endif is the end of the #ifndef HEADER_H. It turns inclusion back on if it was off, and otherwise has no effect. a) is just the usual #include directive, it does no protection against inclusion at all, b) has swapped of the #define and #ifndef directives, and d) has omitted the #define directive.

Computer Science & Information Technology

You might also like to view...

The ________ allows the user to import records from an Excel spreadsheet into an Access table

A) Records Wizard B) Export Spreadsheet Wizard C) Data Wizard D) Import Spreadsheet Wizard

Computer Science & Information Technology

The Wrap Text command displays numbers or formulas on multiple lines as well as text

Indicate whether the statement is true or false

Computer Science & Information Technology

The pop method is used to add items to a Python list.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The expression "*AB" is in _____.

A. prefix notation B. infix notation C. postfix notation D. rpn

Computer Science & Information Technology