Sams Teach Yourself C++ in 21 Days
23: 24: // define the exception classes 25: class xBoundary {}; 26: class xSize 27: { 28: public: 29: xSize(int size):itsSize(si ...
Handling Errors and Exceptions 737 20 71: if (size > 30000) 72: throw xTooBig(size); 73: if (size < 1) 74: throw xNegative ...
119: cout << “You asked for an Array of zero objects!” << endl; 120: cout << “Received “ << theException ...
Handling Errors and Exceptions 739 20 It is tedious and error-prone to have each of these catchstatements individually print the ...
42: class xTooBig : public xSize 43: { 44: public: 45: xTooBig(int size):xSize(size){} 46: virtual void PrintError() 47: { 48: c ...
Handling Errors and Exceptions 741 20 90: 91: Array::Array(int size): 92: itsSize(size) 93: { 94: if (size == 0) 95: throw xZero ...
138: { 139: cout << “Unable to process your input!” << endl; 140: } 141: catch (Array::xSize& theException) 142: ...
Handling Errors and Exceptions 743 20 9: public: 10: // constructors 11: Array(int itsSize = DefaultSize); 12: Array(const Array ...
57: template <class T> 58: Array<T>::Array(const Array<T> &rhs) 59: { 60: itsSize = rhs.GetitsSize(); 61: ...
Handling Errors and Exceptions 745 20 105: catch (xBoundary) 106: { 107: cout << “Unable to process your input!” << ...
One approach to this problem is to put a tryblock around the original call and catch CancelDialogas an exception, which can be r ...
Handling Errors and Exceptions 747 20 All compilers let you compile with or without symbols. Compiling with symbols tells the co ...
generated for each line of your source code. You can examine the memory registers and flags, and generally delve as deep into th ...
Handling Errors and Exceptions 749 20 creation and removal of resources that might be required to properly handle the exceptiona ...
Should you pass exceptions by value or by reference? Will a catchstatement catch a derived exception if it is looking for the b ...
DAY 21 WEEK 3 What’s Next Congratulations! You are nearly done with a full three-week intensive introduc- tion to C++. By now, y ...
The Preprocessor and the Compiler .................................................................... Every time you run your c ...
What’s Next 753 21 Using #definefor Constants.......................................................................... One way ...
#ifndef DEBUG cout << “Debug is not defined.”; #endif Note that #ifndefis the logical reverse of #ifdef. #ifndefevaluates ...
What’s Next 755 21 Checking on the definitions of DemoVersion, NT_VERSION,_and WINDOWS_VERSION... DemoVersion defined. NT_VERSIO ...
«
34
35
36
37
38
39
40
41
42
43
»
Free download pdf