S
Samuele Armondi
Hi,
I'm writing some exception class for a project, and I've got a class called
BasicException that looks like this:
class BasicException
{
private:
std::string Description;
int Number;
public:
BasicException(std::string, int);
friend std:stream& operator << (std:stream&, BasicException&);
};
where the string and the int in the constructor initialize the description
and the error number respectively.
I also have a derived class called InvalidCommand:
class InvalidCommand : public Exceptions::BasicException
{
private:
std::string tmp;
public:
InvalidCommand(std::string s) : tmp((std::string("The command ") + s +
std::string(" is invalid."))), BasicException(tmp, 3) {};
};
the string s is the command name, which is then incorporated into the error
description. This compiles fine in Dev-Cpp (which I always thought had
problems handling string types) but it produces a raft of stupid errors in
VC++ (such as template already defined in <algorithm> and other errors of
the sort.
Is it correct to use the string like I'm using it in the constructor of
InvalidCommand? If it is not, can someone think of another way of doing it?
Thanks in advance,
S. Armondi
I'm writing some exception class for a project, and I've got a class called
BasicException that looks like this:
class BasicException
{
private:
std::string Description;
int Number;
public:
BasicException(std::string, int);
friend std:stream& operator << (std:stream&, BasicException&);
};
where the string and the int in the constructor initialize the description
and the error number respectively.
I also have a derived class called InvalidCommand:
class InvalidCommand : public Exceptions::BasicException
{
private:
std::string tmp;
public:
InvalidCommand(std::string s) : tmp((std::string("The command ") + s +
std::string(" is invalid."))), BasicException(tmp, 3) {};
};
the string s is the command name, which is then incorporated into the error
description. This compiles fine in Dev-Cpp (which I always thought had
problems handling string types) but it produces a raft of stupid errors in
VC++ (such as template already defined in <algorithm> and other errors of
the sort.
Is it correct to use the string like I'm using it in the constructor of
InvalidCommand? If it is not, can someone think of another way of doing it?
Thanks in advance,
S. Armondi