N
Neil Zanella
Hello,
C++ supports the concept of inheritance quite well when it comes to classes.
However, what about other things like enumerations? Suppose I have two functions
foo and bar. I want to restrict input to bar to only a subset of the enueration
types declared in X. But I cannot subclass X from Y!!!
enum X {A, B, C, D};
enum Y {B, C};
void foo(X x);
void bar(Y y);
So what would you recommend. One obvious thing is to have bar return a boolean
and return false if the specified y is an element of (X setminus Y). Not as
neat as I would have liked.
Any recommendations??
Thanks,
neil
C++ supports the concept of inheritance quite well when it comes to classes.
However, what about other things like enumerations? Suppose I have two functions
foo and bar. I want to restrict input to bar to only a subset of the enueration
types declared in X. But I cannot subclass X from Y!!!
enum X {A, B, C, D};
enum Y {B, C};
void foo(X x);
void bar(Y y);
So what would you recommend. One obvious thing is to have bar return a boolean
and return false if the specified y is an element of (X setminus Y). Not as
neat as I would have liked.
Any recommendations??
Thanks,
neil