|
#ifndef Fake_Template_Exception_H_
#define Fake_Template_Exception_H_
#include <string>
class BaseException
{
public:
BaseException();
BaseException(const std::string &what);
virtual ~BaseException() = 0;
BaseException(const BaseException& e);
BaseException& operator=(const BaseException& e);
virtual const char* what() const;
private:
std::string what_;
};
// ---------------------------------------------------------------------------
// This template with fake parameter is used to create derived classes.
// to create your class MyException use construction:
//
// struct MyException_Tag {};
// typedef DerivedException<MyException_Tag> MyException;
//
// ---------------------------------------------------------------------------
template <class>
class DerivedException : public BaseException
{
public:
DerivedException() : BaseException(){ }
explicit DerivedException( const char* what) :
BaseException(what){ }
explicit DerivedException(const std::string &what) :
BaseException(what) { }
virtual ~DerivedException() {};
DerivedException(const DerivedException& e) :
BaseException(e) { }
DerivedException& operator=(const DerivedException& e)
{
BaseException::operator=(e);
return *this;
}
};
#endif //Macro_Exception_H_
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.