-   Programming (
-   -   Makeing my code look cleanner for others (

Starch 02-11-2005 09:55 PM

Makeing my code look cleanner for others
[in c++ using g++ compiler]

I have a class with 2 enums (actually more but for example to simplify things)

        a        =aa,
        b        =bb

        aa        =2,
        bb        =3

Now the second enum I want to be private because its not userfriendly. The problem is the second enum must be first for it to compile. Is there a way I can just keep all the public stuff in one section(beginning) and the rest afterwards.

Currently it looks alitle like a mess because of the enums.

Thanks in advance!

QtCoder 02-15-2005 09:57 PM

Well, as far as I know, you can't do it with G++ (MSVC maybe). What would need to be done is some sort of a forward declaration of your private enum, but forward declaring enums doesn't comply to ansi c++, and therefore doesn't work with G++. (plus, I don't know how an anonymous enum could be forward declared anyway).

You can have multiple public: and private: sections in a class. What I would do is something like this:


class myClass
      enum{aa=2, bb=3};

      enum{a=aa, b=bb};
      // public interface

      // the rest of the private functions & variables

In my opinion, that's very readable.
