What I am trying to do is have a variable that can be accessed statically (i.e. Error::code) but each derived class can set it to a different value.
For example I can have a DownloadError class in which DownloadError::code is set to 1 and FileError::code could be something else. Is this possible or would I have to implement a static virtual function (is this possible?) that returns a constant number?
I'm thinking something like this:
1 2 3 4 5 6 7 8 9 10
class Error {
public:
// other stuff here
staticvirtualint getCode() = 0;
};
class DownloadError : public Error {
public:
staticint getCode() { return 1; }
};
Any help or guidance is greatly appreciated.
EDIT: Members cannot be declared both virtual and static, oh well. Any alternatives still welcome!