I've been rolling C++ "enum"s around in my head and have come up with
a question. Given the following code snippet:
class button
{
public:
enum status (out, in);
void set(status s) {state = s;}
status get() const {return state;}
private:
status state
};
int main()
{
const button::status out = button::out; // #1
const button::status in = button::in; // #2
button panic;
panic.set(out);
[some other stuff]
}
Had the line
button panic;
been declared first in main(), could the verbiage in the line marked
#1 above have been written:
const panic.status out = button::out; ????
I _think_ the question can be rephrased as "why must enums be always
kept separate, apart from the objects to which they can apply?"
I have never heard (nor seen) a REAL explaination of this. Only "here
is the rule. It is not subject to debate. It must be followed."
* KWQ/2 1.2i *
--- TMail v1.31.5
---------------
* Origin: Diablo Valley PCUG-BBS, Walnut Creek, CA 510/943-6238 (1:161/55)
|