Hello,
I have a c++ class and I am trying to run it in ubuntu:
#ifndef WRONGPARAMETEREXCEPTION_H_
#define WRONGPARAMETEREXCEPTION_H_
#include <iostream>
#include <exception>
#include <string>
using namespace std;
#pragma once
class WrongParameterException: public exception
{
public:
WrongParameterException(char* message): exception(message) {};
virtual ~WrongParameterException() throw() {};
};
#endif
when I try to compile it, the compiler gives me this error:
WrongParameterException.h: In constructor ‘WrongParameterException::WrongParameterException(char*)’: WrongParameterException.h:14: error: no matching function for call to ‘std::exception::exception(char*&)’ /usr/include/c++/4.3/exception:59: note: candidates are: std::exception::exception() /usr/include/c++/4.3/exception:57: note: std::exception::exception(const std::exception&)
Can anyone tell me what am I doing wrong? I tried changing the message variable to "string" or "const string" or "const string&" but it didnt help..
Here is how I use the new exception that I created from main:
try
{
if ((strToInt1 == -1) || (parameters[1] == NULL) || (strToInt3 == -1) || (parameters[3] != NULL))
{
throw WrongParameterException("Error in the config or commands file");
}
}
catch(WrongParameterException e)
{
log.addMsg(e.what());
}
Thanks in advance,
Greg