Discussion:
why is there no local parameter of type enum?
(too old to reply)
Zikun Xu
2011-06-13 05:27:35 UTC
Permalink
struct TrieNode {
enum { Apostrophe = 26, NumChars = 27 };
bool isWord;
TrieNode *letters[NumChars];
TrieNode() {
isWord = false;
for ( int i = 0; i < NumChars; i += 1 ) {
letters[i] = NULL;
} // for
}
}; // TrieNode

enum { Apostrophe = 26, NumChars = 27 };
I do not understand how this works, which is the local parameter?
shouldn't we declare a local variable by
enum { Apostrophe = 26, NumChars = 27 } special_char;
Ashif Harji
2011-06-13 17:08:43 UTC
Permalink
In this case, the enum is being used to hold integer constants. This
technique is also used throughout the course notes.

ashif
Post by Zikun Xu
struct TrieNode {
enum { Apostrophe = 26, NumChars = 27 };
bool isWord;
TrieNode *letters[NumChars];
TrieNode() {
isWord = false;
for ( int i = 0; i < NumChars; i += 1 ) {
letters[i] = NULL;
} // for
}
}; // TrieNode
enum { Apostrophe = 26, NumChars = 27 };
I do not understand how this works, which is the local parameter?
shouldn't we declare a local variable by
enum { Apostrophe = 26, NumChars = 27 } special_char;
Loading...