valgrind and throw
[code]#include <stdexcept>#include <iostream>
#include <vector>
class ValgrindRuntimeError : public std::exception {
public:
/** Takes a character string describing the error. */
ValgrindRuntimeError(char s[]) {
_s=new char[strlen(s)];
strcpy(_s, s);
}
virtual ~ValgrindRuntimeError() throw() {
delete[] _s;
}
/** Returns a C-style character string describing the general cause of
* the current error (the same string passed to the ctor). */
virtual const char* what() const throw() {
return _s;
}
private:
char *_s;
};
int main() {
ValgrindRuntimeError a(std::string("xxxx").c_str());
throw a;
}[/code]
页:
[1]