I'm compiling this C++ code with Visual Studio 2012. I noticed that I could use enumeration values without a scope resolution operator (::).
Here's the important parts of my code outside of int main():
enum SortMethod
{
BY_NAME,
BY_WEIGHT
};
Then inside of int main() I use the following:
int main()
{
LinkedList* list = new LinkedList();
/*
Insert values into linked list, in sorted order.
*/
list->print( BY_NAME );
cout << endl << endl;
list->print( BY_WEIGHT );
return 0;
}
Why do these function calls work? The print() function accepts one SortMethod argument. So I figured I would need to do the following:
SortMethod sortByName = BY_NAME;
list->print( sortByName );
But it turns out that I can simply use 'BY_NAME' in the parameter list. Is this compiler-specific?