| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1024 人关注过本帖
标题:定义 C++/CLI枚举
取消只看楼主 加入收藏
hmsabc
Rank: 2
来 自:贵州省兴义市
等 级:论坛游民
帖 子:97
专家分:19
注 册:2010-8-2
结帖率:100%
收藏
 问题点数:0 回复次数:0 
定义 C++/CLI枚举
程序代码:
//定义 C++/CLI枚举

#include "stdafx.h"
//#include <iostream>

using namespace System;

enum class Suit{Clubs,Diamonds,Hearts,Spades};                  //全局范围定义牧举

int main(array<System::String ^> ^args)
{
    Suit suit = Suit::Clubs;                                     //定义 suit 为枚举类变量并使之等于 Clubs
    int value = safe_cast<int>(suit);                            //将 suit 强制类型转换为 int 并赋给 int 类变量 value
    Console::WriteLine(L"Suit is {0} and the value is {1}",suit,value);
    suit = Suit::Diamonds;
    value = safe_cast<int> (suit);
    Console::WriteLine(L"Suit is {0} and the value is {1}",suit,value);
    suit = Suit::Hearts;
    value = safe_cast<int> (suit);
    Console::WriteLine(L"Suit is {0} and the value is {1}",suit,value);
    suit = Suit::Spades;
    value = safe_cast<int> (suit);
    Console::WriteLine(L"Suit is {0} and the value is {1}",suit,value);
    //getchar( );
    //system("pause");
    return 0;
}
搜索更多相关主题的帖子: CLI 定义 枚举 
2010-08-19 22:02
快速回复:定义 C++/CLI枚举
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032297 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved