I'm trying to throw an overflow exception:
Code:void Stack::push(char c) { if(top == max_size) throw Overflow(); }
but I can't find the right header in visual C++ express 2010. Is it #include <stack> ? I'm trying this and it still won't compile.
I'm trying to throw an overflow exception:
Code:void Stack::push(char c) { if(top == max_size) throw Overflow(); }
but I can't find the right header in visual C++ express 2010. Is it #include <stack> ? I'm trying this and it still won't compile.
Although it is more for dynamic memory allocation, I think std::bad_alloc may be the most appropriate, i.e., #include <new> and write:
Code:void Stack::push(char c) { if (top == max_size) throw std::bad_alloc(); }If you are going to use std::stack<char> then you don't need to write your own stack in the first place.Originally Posted by Terrance
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)