I hav received various suggestions from Moschops and others.Pls help me in giving more suggestions guys.Ill use it in a program for a Mathematical parserr.
You are throwing and catching exceptions within the same function, just to output to cerr. Why bother?
Replace throw"Tried to delete top of the Stack,which is a nullptr !!!\n"; with std::cerr<< "Tried to delete top of the Stack,which is a nullptr !!!\n"; and similarly for others.
Normally you throw exceptions in the code that has to report an error it can't handle. You catch an exception when you can deal with the error.
Stack :: ~Stack()
Why would you want to throw an exception here. An empty stack is not an error. void Stack :: pop()
Trying to pop an empty stack is definitely an error and should be reported to the caller. void Stack :: push(int &a)
How can yo actually get an stack overflow? If there is not enough memory you will get an bad_alloc exception from new