NH> I've been rolling C++ "enum"s around in my head and have come up with
NH> a question. Given the following code snippet:
NH> class button
NH> {
NH> public:
NH> enum status (out, in);
enum status {out, in}; // :-)
NH> void set(status s) {state = s;}
NH> status get() const {return state;}
NH> private:
NH> status state
NH> };
NH> int main()
NH> {
NH> const button::status out = button::out; // #1
NH> const button::status in = button::in; // #2
NH> button panic;
NH> panic.set(out);
panic.set(button::out);
panic.set(panic.out); // ? Can't recall... maybe this is object pascal...
NH> [some other stuff]
NH> }
NH> Had the line
NH> button panic;
NH> been declared first in main(), could the verbiage in the line marked
NH> #1 above have been written:
NH> const panic.status out = button::out; ????
Nope. Its type is button::out. It might be able to be panic::out, but I
can't recall right now. :-/ Try it! :-)
NH> I _think_ the question can be rephrased as "why must enums be always
NH> kept separate, apart from the objects to which they can apply?"
I'm unsure of the question. Perhaps someone else will understand and answer,
otherwise try rewording it. A list of my vocabulary... (Sorry, too many of
those text-adventure games )
--- Maximus/2 3.01
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|