
April 25th, 2005, 05:18 PM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 5
Time spent in forums: 34 m 8 sec
Reputation Power: 0
|
|
|
How to use enum when it is in another class/namespace
Trying to use an enumerated type when it is in another class which is in another namespace, and I'm having problems since I don't know how to set the values (other than by integers)
Here is some example code:
Code:
namespace ns {
class cls {
public:
enum color { black, white };
}; // end cls
} // end ns
int main() {
ns::cls::color c;
// How Do I set c to be black?
}
I realize that I can use:
Code:
c = (ns::cls::color) 0;
However, that defeats the purposes of namespaces...
Anyone please tell me how to set c to black by actually using the enumerated type?
Thanks
|