I was trying to run a simple example in class based on exceptions. The teacher uses microsoft visual studio so I thought it was microsoft's implementation error rather than the actual mingw libraries. In the code it throws this exception.
Code:
int pop( )
{
if( empty( ) )
throw exception( "Attempt to pop from empty stack!" );
return stack[ --top ];
}
but I get the error
4338\exceptions\IntStack.h:39: error: no matching function for call to `std::exception::exception(const char[33])'
53: note: candidates are: std::exception::exception(const std::exception&)
55: note: std::exception::exception()
158: error: `main' must return `int'
:: === Build finished: 4 errors, 0 warnings ===
I wondered if the example was wrong but whenI looked at the Mingw exception.h it only has this as the exception class declaration
Code:
class exception
{
public:
exception() throw() { }
virtual ~exception() throw();
/** Returns a C-style character string describing the general cause
* of the current error. */
virtual const char* what() const throw();
};
but when I looked on the MSND library it has this for the exception class it has it declared as this...do I have the wrong class or something?
Code:
class exception
{
public:
exception() throw() { }
virtual ~exception() throw();
/** Returns a C-style character string describing the general cause
* of the current error. */
virtual const char* what() const throw();
};