Thursday, January 26, 2012

Basic usage of enum class in CLR C++

// testENUM_CLR.cpp : main project file.

#include "stdafx.h"

using namespace System;

enum class Day {SUN, MON, TUE, WED, THU, FRI, SAT};

int main(array<System::String ^> ^args)
{
    Console::WriteLine(L"http://dev-microsoft.blogspot.com/");

 Console::WriteLine("");
 Console::WriteLine(L"Day {0} have value of {1}.", Day::SUN, safe_cast<int>(Day::SUN));
 Console::WriteLine(L"Day {0} have value of {1}.", Day::MON, safe_cast<int>(Day::MON));
 Console::WriteLine(L"Day {0} have value of {1}.", Day::TUE, safe_cast<int>(Day::TUE));
 Console::WriteLine(L"Day {0} have value of {1}.", Day::WED, safe_cast<int>(Day::WED));
 Console::WriteLine(L"Day {0} have value of {1}.", Day::THU, safe_cast<int>(Day::THU));
 Console::WriteLine(L"Day {0} have value of {1}.", Day::FRI, safe_cast<int>(Day::FRI));
 Console::WriteLine(L"Day {0} have value of {1}.", Day::SAT, safe_cast<int>(Day::SAT));

 Console::ReadLine();
    return 0;
}

Basic usage of enum class in CLR C++

Compare to Basic usage of enum in C++

No comments:

Post a Comment