#include <stdexcept>
#include <string>
using namespace std;
class ListIndexOutOfRangeException : public out_of_range
{
public:
ListIndexOutOfRangeException(const string & message = "") : out_of_range(message.c_str())
{
}
}; // end ListIndexOutOfRangeException
views:
81answers:
1
+1
A:
out_of_range
accepts a string reference, so just use
: out_of_range(message)
instead.
edit:
And as others have said, the compiler is telling you you have used message.cstr()
instead of message.c_str()
. But the method call is unnecessary anyway, just pass the string.
Mike Weller
2009-12-20 11:42:53
Nice one! Thanks.
Brandon
2009-12-20 11:45:38