enumeration as member variable

hi, I want to know why those enumerations are defined as public members of the class in the following codes

I think those such as SELECT_ORDER,SELECT_TYPE are just types,not variables.
how could they be a member variable in the class?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

class ConfigPeer : public Peer
{
public:
	enum SELECT_ORDER {ChunkFirst, PeerFirst, Mixed};
	enum SELECT_TYPE {Best, Weighted};
	enum CHUNK_FILTER {AllChunks, UsefulToSelected, UsefulToSomeone};
	enum PEER_FILTER {AllPeers, NeedsAny, NeedsSelected};
private:
        SELECT_ORDER sel_order;
	SELECT_TYPE chunk_sel_type;
	SELECT_TYPE peer_sel_type;
	CHUNK_FILTER chunk_filter;
	PEER_FILTER peer_filter;
.....
.....
This is so code outside the class can use these enumerations as well. Which is likely necessary/useful in some of this class's member functions.

If, for example, ConfigPeer has a function like SetFilter and takes a value of type PEER_FILTER -- in order for code outside the class to reasonably be able to make use of that function, the enum would need to be made public.

IE: outside code could do ConfigPeer::PEER_FILTER filter = ConfigPeer::AllPeers;. This can not be done if those enums are not public.
Topic archived. No new replies allowed.