IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New C++ Question
(And no, this isn't an invitation for a flame war...we've got enough of that going on in Politics already ;-) )

C++ allows what I will call "incomplete definition" of types. That is, you can declare part of a class in one plase, and the rest of the class in another, with the entire class being compiled together in the same compilation unit. For example:
\nclass Foo\n{\npublic:\n\n   int    a;\n\n          Foo(void);\n};\n\n// sometime later in the same compilation unit\n\nclass Foo\n{\npublic:\n\n    int    b;\n\n          ~Foo();\n};\n\nmain(int argc, void ** argv)\n{\n    Foo *   bar = new Foo;    //invokes constructor from 1st declaration\n\n    bar->a = 0;\n    bar->b = 1;\n\n    ...\n\n    delete bar;\n}\n


The question is this: Can one do the same with enum type declarations (that is, split the declaration up)? I can find nothing in the ANSI standard that either allows or precludes this.
jb4
shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT

New Begs the question
...but I see that C# 2.0 allows [link|http://www.ondotnet.com/pub/a/dotnet/2004/04/05/csharpwhidbeypt1.html|partial classes].
New OT: Anonymous methods - looks like a proper closure
--

Buy high, sell sober.
New Getting closer - probably did it just to po java
And keeping to the parallel universe, I see that c# does not allow [link|http://msdn.microsoft.com/msdnmag/issues/04/05/C20/default.aspx|Partial Enums]:

In fact, you can have as many parts as you like in any given class. Partial type support is available for classes, structures, and interfaces, but you cannot have a partial enum definition.


Probably doesn't have any relevance to the original C++ question. :-)
New What question is that?
By the way, I got a chuckle of the animal that O'Reilly chose to adorn the cover of its C-pigpen book:
[image|http://www.oreilly.com/catalog/covers/progcsharp3.s.gif||||]

That is a female peacock!

People got a sense o' humor, they got!
jb4
shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT

New How to avoid a C++ flamefest...
...bring C# into the fray. :-)

My inclination is to say that partial enums are probably not supported, due to the way they are usually represented. In the case of classes, structures, etc, you are defining seperate fields. In the case of enums, all the enumerations are generally put into one data field.

Doesn't mean a smart compiler can't do it, but then the ordering of enumerations has an effect on the actual ordinal assigned to the enumeration. Which probably means the compiler doesn't like having them scattered about.
New Good point
..about the ordering, that is. ;-)

Having them scattered about means that one cannot generally identify what the constant value of an enumerator is (unless, of course, the writer went to the trouble of assigning values to at least the first one of each partial declaration). Now, one might argue that this is a Good Thing, as one should treat enums as enums, not as a bastard form of int, but that also invites a flame war that I'm not interested in starting, either!
jb4
shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT

New They are essentially the same as C enums
with stronger notions of typing. Which is to say enum Fish {} defines a unique type Fish with automatic promotion to int.

Staying compatible with C implies that you can't expand an enum later.

This has been something of annoyance to a lot of people. Especially when wanting to scope an enum definition to a class, then subclass and extend.

But that's how they work now. AFAIK. Unless its been changed in the last 6 years or so. I stopped following the language when I stopped using it.




Democracies are not well-run nor long-preserved with secrecy and lies.

     --Walter Cronkite
New Bummah!
This has been something of annoyance to a lot of people. Especially when wanting to scope an enum definition to a class, then subclass and extend.

Which is, of course, exactly what we want to do, which is the source of the question.

I thought I recalled seeing somewhere that this was allowed, but in retrospect, I think it was wishful thinking ;-) !
jb4
shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT

     C++ Question - (jb4) - (8)
         Begs the question - (ChrisR) - (5)
             OT: Anonymous methods - looks like a proper closure -NT - (Arkadiy) - (1)
                 Getting closer - probably did it just to po java - (ChrisR)
             What question is that? - (jb4) - (2)
                 How to avoid a C++ flamefest... - (ChrisR) - (1)
                     Good point - (jb4)
         They are essentially the same as C enums - (tuberculosis) - (1)
             Bummah! - (jb4)

Obeying the Law of Gravity since 2001.
58 ms