Sams Teach Yourself C++ in 21 Days

(singke) #1
42: class xTooBig : public xSize
43: {
44: public:
45: xTooBig(int size):xSize(size){}
46: virtual void PrintError()
47: {
48: cout << “Too big! Received: “;
49: cout << xSize::itsSize << endl;
50: }
51: };
52:
53: class xTooSmall : public xSize
54: {
55: public:
56: xTooSmall(int size):xSize(size){}
57: virtual void PrintError()
58: {
59: cout << “Too small! Received: “;
60: cout << xSize::itsSize << endl;
61: }
62: };
63:
64: class xZero : public xTooSmall
65: {
66: public:
67: xZero(int size):xTooSmall(size){}
68: virtual void PrintError()
69: {
70: cout << “Zero!!. Received: “ ;
71: cout << xSize::itsSize << endl;
72: }
73: };
74:
75: class xNegative : public xSize
76: {
77: public:
78: xNegative(int size):xSize(size){}
79: virtual void PrintError()
80: {
81: cout << “Negative! Received: “;
82: cout << xSize::itsSize << endl;
83: }
84: };
85:
86: private:
87: int *pType;
88: int itsSize;
89: };

740 Day 20


LISTING20.8 continued
Free download pdf