Multiple Read Protection [#ifndef – 2] What if we have, say, 4 class headers being stored in one file, for convenience. Would we use ONE #ifndef directive or MULTIPLE #ifndef directives around each individual class header?
You would just protect the whole file. The purpose of a header file inclusion is to supply defintions of classes or functions to a client program. This does not “bulk up” the executable, it just provides information used in the compile process. Thus there is no harm in over-supplying definitions. Of course, you could go overboard with this, throwing hundreds of class defintions into one file, then the compile process would get noticably slowed by packing the (temporary) symbol table with unneeded terms. Good design will prevent such excesses by having only a collection of related classes defined in the same file.
Related Questions
- If all files and documents of all users are stored on the same server on the same storage device, can one user not access or read the files of another user?
- Can I just read a book, attend a parenting class, and talk with family and friends to get the help I need for my child or adolescent?
- How can I read the data stored in the particular cell of the Excel spreadsheet?