NcException copy constructor and assignment operators defined

This commit is contained in:
Jarle Ladstein 2013-12-09 18:11:50 +01:00
parent 127ff36095
commit 4b57c61161
2 changed files with 24 additions and 0 deletions

View File

@ -18,6 +18,28 @@ NcException::NcException(const string& exceptionNameIn,const string& complaintIn
}
}
NcException::NcException(const NcException& e) throw()
: what_msg(nullptr)
{
try{
what_msg = new std::string(*(e.what_msg));
}catch(...){
what_msg = nullptr;
}
}
NcException& NcException::operator=(const NcException& e) throw(){
if (this != &e){
delete what_msg;
try{
what_msg = new std::string(*(e.what_msg));
}catch(...){
what_msg = nullptr;
}
}
return *this;
}
NcException::~NcException()throw() {
delete what_msg;
}

View File

@ -24,6 +24,8 @@ namespace netCDF
class NcException : public std::exception {
public:
NcException(const std::string& exceptionName,const std::string& complaint,const char* fileName,int lineNumber);
NcException(const NcException& e) throw();
NcException& operator=(const NcException& e) throw();
virtual ~NcException() throw();
const char* what() const throw();
private: