Enum.cpp
上传用户:sz0451
上传日期:2022-07-29
资源大小:256k
文件大小:1k
- // This is the main project file for VC++ application project
- // generated using an Application Wizard.
- #include "stdafx.h"
- #using <mscorlib.dll>
- #include <tchar.h>
- using namespace System;
- __value enum Weekday : char {
- Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
- };
- // This is the entry point for this application
- int _tmain(void)
- {
- Console::WriteLine(S"Enum example");
- Weekday w = Monday;
- Console::WriteLine(w);
- // This doesn't work...
- //w = 8;
- // Assigning an enum to an int is OK
- int n = Monday;
- // Switch on the enum
- switch(w) {
- case Monday:
- Console::WriteLine("It's Monday");
- break;
- case Tuesday:
- Console::WriteLine("It's Tuesday");
- break;
- default:
- Console::WriteLine("It's some other day");
- }
- return 0;
- }