May 2002
Beginner
320 pages
6h 18m
English
Remember the function Initialize(), which was used to prepare cin for throwing exceptions? What if you moved error handling out to a module of its own, and some other library or main program wanted to use that common name? This could be a problem.
You have already seen a way to deal with this possibility: namespaces. That's the solution iostream uses and it will work perfectly for this situation.
The form of a namespace declaration is
namespace namespacename { statements } ;
Listing 8.3 is the new header file.
1: #ifndef ErrorHandlingModuleH 2: #define ErrorHandlingModuleH 3: *4: namespace SAMSErrorHandling *5: { 6: void Initialize(void); 7: int HandleNotANumberError(void); ... |
Read now
Unlock full access