TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: NEIL HELLER
date: 1997-09-13 21:49:00
subject: Why this construction?

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.