标题:
valgrind and throw
[打印本页]
作者:
cnangel
时间:
2012-7-25 10:54
标题:
valgrind and throw
#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;
}
复制代码
欢迎光临 星星博客 (http://commerce.huhoo.net/)
Powered by Discuz! 7.0.0