// cl /EHsc test3.cpp #include using std::cout; using std::endl; #include "tStack3.h" int main() { Stack iStack(30); Stack cStack(30); int i; try { for (i=0; i<25; i++) iStack.push(i); for (i=0; i<26; i++) { cout << iStack.top() << ' '; iStack.pop(); } } catch (top_out_of_range &e) { cout << "\n" << e.what() << endl; } try { for (i=0; i<25; i++) cStack.push(i); for (i=0; i<26; i++) { cout << (int) cStack.top() << ' '; cStack.pop(); } } catch (top_out_of_range &e) { cout << "\n" << e.what() << endl; } try { cout << cStack.top() << endl;; } catch (top_out_of_range &e) { cout << "\n" << e.what() << endl; } try { for (i=0; i<31; i++) iStack.push(i); } catch (push_out_of_range &e) { cout << "\n" << e.what() << endl; } return 0; }