I've tried about 20 attempts & read numerous pages for the last 2 hours and can't figure out what I'm doing wrong here:
#pragma once
#include <exception>
using namespace std;
class EmptyHeap : public exception {
public:
virtual const char* what() const throw()
{
return "The heap is empty!";
}
};
Then in the heap class, a public method:
void remove() throw()//EmptyHeap
{
if (isEmpty())
{
EmptyHeap broken;
throw broken;
}
...
This code works, but the original header was:
void remove() throw EmptyHeap;
Is there a way to specify what exception a method throws in C++, or is that just a Java thing?