Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-11-2005, 08:55 PM   #1
Registered: Jan 2005
Posts: 77

Rep: Reputation: 15
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!
Old 02-15-2005, 08:57 PM   #2
Registered: Aug 2003
Location: USA
Distribution: Slackware 12.0 RC1
Posts: 129

Rep: Reputation: 15
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.

Last edited by QtCoder; 02-15-2005 at 09:25 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
oooooo so close to makeing this work. Goblin_C_Noob Programming 4 09-11-2005 05:44 AM
makeing my own linux einstien Linux - General 5 02-22-2005 09:23 AM
error makeing k3b what do i do? glenn69 Linux - Newbie 1 09-12-2004 04:14 PM
makeing a music server awc2005 Linux - Networking 3 03-04-2004 09:32 PM
I want some help on makeing my own Linux distro Posty Linux - Distributions 14 10-21-2003 10:12 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:38 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration