From: Aaron W. L. <aar...@aa...> - 2005-03-01 06:18:38
|
Greg Chicares wrote: > To ensure portability, explicitly include the header for > every standard-library facility you use. Here's a classic Since "use" may be difficult to define, and I think getting this right is very important (We don't want to include headers if we really don't need to.), let me offer my own personal stylistic guideline. If you use a name (such as a macro or function) that is not declared within the file you are working in (whether it is a normal source file or a header file), include the header who's interface (presumably documented) specifies that it shall declare that name. The main consequence of this is that you include headers--such as <utility>--even when you know that the needed declaration must be present anyway. A second consequence of this is that you don't include headers if you are 'using' an object or type without actually ever knowing its name. This reduces coupling in a desirable manner. Aaron W. LaFramboise |